Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
|
Performs database administration operations on Spanner. More...
#include <google/cloud/spanner/database_admin_client.h>
Public Member Functions | |
DatabaseAdminClient (ConnectionOptions const &options=ConnectionOptions()) | |
future< StatusOr< google::spanner::admin::database::v1::Database > > | CreateDatabase (Database db, std::vector< std::string > extra_statements={}, EncryptionConfig encryption_config=DefaultEncryption()) |
Creates a new Cloud Spanner database in the given project and instance. More... | |
StatusOr< google::spanner::admin::database::v1::Database > | GetDatabase (Database db) |
Retrieve metadata information about a database. More... | |
StatusOr< google::spanner::admin::database::v1::GetDatabaseDdlResponse > | GetDatabaseDdl (Database db) |
Retrieve a database schema. More... | |
future< StatusOr< google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata > > | UpdateDatabase (Database db, std::vector< std::string > statements) |
Updates the database using a series of DDL statements. More... | |
Status | DropDatabase (Database db) |
Drops (deletes) an existing Cloud Spanner database. More... | |
ListDatabaseRange | ListDatabases (Instance in) |
List all the databases in a give project and instance. More... | |
future< StatusOr< google::spanner::admin::database::v1::Database > > | RestoreDatabase (Database db, Backup const &backup, EncryptionConfig encryption_config=DefaultEncryption()) |
Create a new database by restoring from a completed backup. More... | |
future< StatusOr< google::spanner::admin::database::v1::Database > > | RestoreDatabase (Database db, google::spanner::admin::database::v1::Backup const &backup, EncryptionConfig encryption_config=DefaultEncryption()) |
Create a new database by restoring from a completed backup. More... | |
StatusOr< google::iam::v1::Policy > | GetIamPolicy (Database db) |
Gets the IAM policy for a database. More... | |
StatusOr< google::iam::v1::Policy > | SetIamPolicy (Database db, google::iam::v1::Policy policy) |
Set the IAM policy for the given database. More... | |
StatusOr< google::iam::v1::Policy > | SetIamPolicy (Database const &db, IamUpdater const &updater) |
Updates the IAM policy for an instance using an optimistic concurrency control loop. More... | |
StatusOr< google::iam::v1::Policy > | SetIamPolicy (Database const &db, IamUpdater const &updater, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy) |
Updates the IAM policy for an instance using an optimistic concurrency control loop. More... | |
StatusOr< google::iam::v1::TestIamPermissionsResponse > | TestIamPermissions (Database db, std::vector< std::string > permissions) |
Get the subset of the permissions the caller has on the given database. More... | |
future< StatusOr< google::spanner::admin::database::v1::Backup > > | CreateBackup (Database db, std::string backup_id, Timestamp expire_time, absl::optional< Timestamp > version_time=absl::nullopt, EncryptionConfig encryption_config=DefaultEncryption()) |
Creates a new Cloud Spanner backup for the given database. More... | |
future< StatusOr< google::spanner::admin::database::v1::Backup > > | CreateBackup (Database db, std::string backup_id, std::chrono::system_clock::time_point expire_time) |
Creates a new Cloud Spanner backup for the given database. More... | |
StatusOr< google::spanner::admin::database::v1::Backup > | GetBackup (Backup const &backup) |
Retrieve metadata information about a Backup. More... | |
Status | DeleteBackup (google::spanner::admin::database::v1::Backup const &backup) |
Deletes a pending or completed Backup. More... | |
Status | DeleteBackup (Backup const &backup) |
Deletes a pending or completed Backup. More... | |
ListBackupsRange | ListBackups (Instance in, std::string filter={}) |
List all the backups in a given project and instance that match the filter. More... | |
StatusOr< google::spanner::admin::database::v1::Backup > | UpdateBackupExpireTime (google::spanner::admin::database::v1::Backup const &backup, Timestamp expire_time) |
Update backup's expire_time . More... | |
StatusOr< google::spanner::admin::database::v1::Backup > | UpdateBackupExpireTime (Backup const &backup, Timestamp expire_time) |
Update backup's expire_time . More... | |
StatusOr< google::spanner::admin::database::v1::Backup > | UpdateBackupExpireTime (google::spanner::admin::database::v1::Backup const &backup, std::chrono::system_clock::time_point const &expire_time) |
Update backup's expire_time . More... | |
StatusOr< google::spanner::admin::database::v1::Backup > | UpdateBackupExpireTime (Backup const &backup, std::chrono::system_clock::time_point const &expire_time) |
Update backup's expire_time . More... | |
ListBackupOperationsRange | ListBackupOperations (Instance in, std::string filter={}) |
List all the backup operations in a given project and instance that match the filter. More... | |
ListDatabaseOperationsRange | ListDatabaseOperations (Instance in, std::string filter={}) |
List all the database operations in a given project and instance that match the filter. More... | |
DatabaseAdminClient (std::shared_ptr< DatabaseAdminConnection > c) | |
Create a new client with the given stub. For testing only. More... | |
Performs database administration operations on Spanner.
Applications use this class to perform administrative operations on spanner Databases.
Creating a new DatabaseAdminClient
is a relatively expensive operation, new objects establish new connections to the service. In contrast, copying or moving an existing DatabaseAdminClient
object is a relatively cheap operation. Copied clients share the underlying resources.
Instances of this class created via copy-construction or copy-assignment share the underlying pool of connections. Access to these copies via multiple threads is guaranteed to work. Two threads operating on the same instance of this class is not guaranteed to work.
This class uses StatusOr<T>
to report errors. When an operation fails to perform its work the returned StatusOr<T>
contains the error details. If the ok()
member function in the StatusOr<T>
returns true
then it contains the expected result. For more information, see the Error Handling Guide.
Some operations in this class can take minutes to complete. In this case the class returns a google::cloud::future<StatusOr<T>>
, the application can then poll the future
or associate a callback to be invoked when the operation completes:
|
explicit |
|
inlineexplicit |
Create a new client with the given stub. For testing only.
future< StatusOr< google::spanner::admin::database::v1::Backup > > google::cloud::spanner::DatabaseAdminClient::CreateBackup | ( | Database | db, |
std::string | backup_id, | ||
std::chrono::system_clock::time_point | expire_time | ||
) |
Creates a new Cloud Spanner backup for the given database.
Timestamp
overload instead.This function creates a database backup for the given Google Cloud Spanner database.
Note that the backup_id
must be unique within the same instance, it must be between 2 and 60 characters long, it must start with a lowercase letter ([a-z]
), it must end with a lowercase letter or a number ([a-z0-9]
) and any characters between the beginning and ending characters must be lower case letters, numbers, underscore (_
) or dashes (-
), that is, they must belong to the [a-z0-9_-]
character set.
The expire_time
must be at least 6 hours and at most 366 days from the time the CreateBackup()
request is processed.
google::cloud::future
that becomes satisfied when the operation completes on the service. Note that this can take minutes in some cases. future< StatusOr< google::spanner::admin::database::v1::Backup > > google::cloud::spanner::DatabaseAdminClient::CreateBackup | ( | Database | db, |
std::string | backup_id, | ||
Timestamp | expire_time, | ||
absl::optional< Timestamp > | version_time = absl::nullopt , |
||
EncryptionConfig | encryption_config = DefaultEncryption() |
||
) |
Creates a new Cloud Spanner backup for the given database.
This function creates a database backup for the given Google Cloud Spanner database.
Note that the backup_id
must be unique within the same instance, it must be between 2 and 60 characters long, it must start with a lowercase letter ([a-z]
), it must end with a lowercase letter or a number ([a-z0-9]
) and any characters between the beginning and ending characters must be lower case letters, numbers, underscore (_
) or dashes (-
), that is, they must belong to the [a-z0-9_-]
character set.
The expire_time
must be at least 6 hours and at most 366 days from the time the CreateBackup()
request is processed.
The backup will contain an externally consistent copy of the database at version_time
, if set. Otherwise, the version_time will be the create_time of the backup.
encryption_config
How to encrypt the backup.
google::cloud::future
that becomes satisfied when the operation completes on the service. Note that this can take minutes in some cases.future< StatusOr< google::spanner::admin::database::v1::Database > > google::cloud::spanner::DatabaseAdminClient::CreateDatabase | ( | Database | db, |
std::vector< std::string > | extra_statements = {} , |
||
EncryptionConfig | encryption_config = DefaultEncryption() |
||
) |
Creates a new Cloud Spanner database in the given project and instance.
This function creates a database (using the "CREATE DATABASE" DDL statement) in the given Google Cloud Project and Cloud Spanner instance. The application can provide an optional list of additional DDL statements to atomically create tables and indices as well as the new database.
Note that the database id must be between 2 and 30 characters long, it must start with a lowercase letter ([a-z]
), it must end with a lowercase letter or a number ([a-z0-9]
) and any characters between the beginning and ending characters must be lower case letters, numbers, underscore (_
) or dashes (-
), that is, they must belong to the [a-z0-9_-]
character set.
encryption_config
How to encrypt the database.
google::cloud::future
that becomes satisfied when the operation completes on the service. Note that this can take minutes in some cases.Deletes a pending or completed Backup.
Status google::cloud::spanner::DatabaseAdminClient::DeleteBackup | ( | google::spanner::admin::database::v1::Backup const & | backup | ) |
Deletes a pending or completed Backup.
Drops (deletes) an existing Cloud Spanner database.
StatusOr< google::spanner::admin::database::v1::Backup > google::cloud::spanner::DatabaseAdminClient::GetBackup | ( | Backup const & | backup | ) |
Retrieve metadata information about a Backup.
StatusOr< google::spanner::admin::database::v1::Database > google::cloud::spanner::DatabaseAdminClient::GetDatabase | ( | Database | db | ) |
Retrieve metadata information about a database.
StatusOr< google::spanner::admin::database::v1::GetDatabaseDdlResponse > google::cloud::spanner::DatabaseAdminClient::GetDatabaseDdl | ( | Database | db | ) |
Retrieve a database schema.
StatusOr< google::iam::v1::Policy > google::cloud::spanner::DatabaseAdminClient::GetIamPolicy | ( | Database | db | ) |
Gets the IAM policy for a database.
ListBackupOperationsRange google::cloud::spanner::DatabaseAdminClient::ListBackupOperations | ( | Instance | in, |
std::string | filter = {} |
||
) |
List all the backup operations in a given project and instance that match the filter.
in | An instance where the backup operations belong to. |
filter | A filter expression that filters what operations are returned in the response. See this documentation for the syntax of the filter expression. |
ListBackupsRange google::cloud::spanner::DatabaseAdminClient::ListBackups | ( | Instance | in, |
std::string | filter = {} |
||
) |
List all the backups in a given project and instance that match the filter.
in | An instance where the backup operations belong to. |
filter | A filter expression that filters backups listed in the response. See this documentation for the syntax of the filter expression. |
ListDatabaseOperationsRange google::cloud::spanner::DatabaseAdminClient::ListDatabaseOperations | ( | Instance | in, |
std::string | filter = {} |
||
) |
List all the database operations in a given project and instance that match the filter.
in | An instance where the database operations belong to. |
filter | A filter expression that filters what operations are returned in the response. See this documentation for the syntax of the filter expression. |
ListDatabaseRange google::cloud::spanner::DatabaseAdminClient::ListDatabases | ( | Instance | in | ) |
List all the databases in a give project and instance.
future< StatusOr< google::spanner::admin::database::v1::Database > > google::cloud::spanner::DatabaseAdminClient::RestoreDatabase | ( | Database | db, |
Backup const & | backup, | ||
EncryptionConfig | encryption_config = DefaultEncryption() |
||
) |
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.
encryption_config
How to encrypt the database.
google::cloud::future
that becomes satisfied when the operation completes on the service. Note that this can take minutes in some cases.future< StatusOr< google::spanner::admin::database::v1::Database > > google::cloud::spanner::DatabaseAdminClient::RestoreDatabase | ( | Database | db, |
google::spanner::admin::database::v1::Backup const & | backup, | ||
EncryptionConfig | encryption_config = DefaultEncryption() |
||
) |
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.
encryption_config
How to encrypt the database.
google::cloud::future
that becomes satisfied when the operation completes on the service. Note that this can take minutes in some cases. StatusOr< google::iam::v1::Policy > google::cloud::spanner::DatabaseAdminClient::SetIamPolicy | ( | Database const & | db, |
IamUpdater const & | updater | ||
) |
Updates the IAM policy for an instance using an optimistic concurrency control loop.
This function repeatedly reads the current IAM policy in db
, and then calls the updater
with the this policy. The updater
returns an empty optional if no changes are required, or it returns the new desired value for the IAM policy. This function then updates the policy.
Updating an IAM policy can fail with retryable errors or can be aborted because there were simultaneous changes the to IAM policy. In these cases this function reruns the loop until it succeeds.
The function returns the final IAM policy, or an error if the rerun policy for the underlying connection has expired.
etag
field on the policy, so the underlying RPCs are retried automatically.db | the identifier for the database where you want to change the IAM policy. |
updater | a callback to modify the policy. Return an unset optional to indicate that no changes to the policy are needed. |
StatusOr< google::iam::v1::Policy > google::cloud::spanner::DatabaseAdminClient::SetIamPolicy | ( | Database const & | db, |
IamUpdater const & | updater, | ||
std::unique_ptr< TransactionRerunPolicy > | rerun_policy, | ||
std::unique_ptr< BackoffPolicy > | backoff_policy | ||
) |
Updates the IAM policy for an instance using an optimistic concurrency control loop.
This function repeatedly reads the current IAM policy in db
, and then calls the updater
with the this policy. The updater
returns an empty optional if no changes are required, or it returns the new desired value for the IAM policy. This function then updates the policy.
Updating an IAM policy can fail with retryable errors or can be aborted because there were simultaneous changes the to IAM policy. In these cases this function reruns the loop until it succeeds.
The function returns the final IAM policy, or an error if the rerun policy for the underlying connection has expired.
etag
field on the policy, so the underlying RPCs are retried automatically.db | the identifier for the database where you want to change the IAM policy. |
updater | a callback to modify the policy. Return an unset optional to indicate that no changes to the policy are needed. |
rerun_policy | controls for how long (or how many times) the updater will be rerun after the IAM policy update aborts. |
backoff_policy | controls how long SetIamPolicy waits between reruns. |
StatusOr< google::iam::v1::Policy > google::cloud::spanner::DatabaseAdminClient::SetIamPolicy | ( | Database | db, |
google::iam::v1::Policy | policy | ||
) |
Set the IAM policy for the given database.
This function changes the IAM policy configured in the given database to the value of policy
.
etag
field in policy
is set. Therefore, the underlying RPCs are only retried if the field is set, and the function returns the first RPC error in any other case.StatusOr< google::iam::v1::TestIamPermissionsResponse > google::cloud::spanner::DatabaseAdminClient::TestIamPermissions | ( | Database | db, |
std::vector< std::string > | permissions | ||
) |
Get the subset of the permissions the caller has on the given database.
This function compares the given list of permissions against those permissions granted to the caller, and returns the subset of the list that the caller actually holds.
spanner.*
are not allowed.StatusOr< google::spanner::admin::database::v1::Backup > google::cloud::spanner::DatabaseAdminClient::UpdateBackupExpireTime | ( | Backup const & | backup, |
std::chrono::system_clock::time_point const & | expire_time | ||
) |
Update backup's expire_time
.
Timestamp
overload instead.StatusOr< google::spanner::admin::database::v1::Backup > google::cloud::spanner::DatabaseAdminClient::UpdateBackupExpireTime | ( | Backup const & | backup, |
Timestamp | expire_time | ||
) |
Update backup's expire_time
.
StatusOr< google::spanner::admin::database::v1::Backup > google::cloud::spanner::DatabaseAdminClient::UpdateBackupExpireTime | ( | google::spanner::admin::database::v1::Backup const & | backup, |
std::chrono::system_clock::time_point const & | expire_time | ||
) |
Update backup's expire_time
.
Timestamp
overload instead.StatusOr< google::spanner::admin::database::v1::Backup > google::cloud::spanner::DatabaseAdminClient::UpdateBackupExpireTime | ( | google::spanner::admin::database::v1::Backup const & | backup, |
Timestamp | expire_time | ||
) |
Update backup's expire_time
.
future< StatusOr< google::spanner::admin::database::v1::UpdateDatabaseDdlMetadata > > google::cloud::spanner::DatabaseAdminClient::UpdateDatabase | ( | Database | db, |
std::vector< std::string > | statements | ||
) |
Updates the database using a series of DDL statements.
This function schedules a series of updates to the database using a sequence of DDL statements.
google::cloud::future
that becomes satisfied when all the statements complete. Note that Cloud Spanner may fail to execute some of the statements.