16 #include "google/cloud/internal/disable_deprecation_warnings.inc"
17 #include "google/cloud/spanner/database_admin_client.h"
18 #include "google/cloud/spanner/timestamp.h"
26 namespace gcsa = ::
google::spanner::admin::database::v1;
32 Database db, std::vector<std::string> extra_statements,
33 EncryptionConfig encryption_config) {
34 return conn_->
CreateDatabase({std::move(db), std::move(extra_statements),
35 std::move(encryption_config)}
);
47 future<StatusOr<gcsa::UpdateDatabaseDdlMetadata>>
49 std::vector<std::string> statements) {
62 Database db,
Backup const& backup, EncryptionConfig encryption_config) {
64 {std::move(db), backup
.FullName(), std::move(encryption_config)}
);
68 Database db,
google::spanner::admin::database::v1::Backup
const& backup,
69 EncryptionConfig encryption_config) {
71 {std::move(db), backup.name(), std::move(encryption_config)}
);
85 Database const& db, IamUpdater
const& updater) {
86 auto const rerun_maximum_duration = std::chrono::minutes(15);
87 auto default_rerun_policy =
88 LimitedTimeTransactionRerunPolicy(rerun_maximum_duration).clone();
90 auto const backoff_initial_delay = std::chrono::milliseconds(1000);
91 auto const backoff_maximum_delay = std::chrono::minutes(5);
92 auto const backoff_scaling = 2.0;
93 auto default_backoff_policy =
94 ExponentialBackoffPolicy(backoff_initial_delay, backoff_maximum_delay,
99 std::move(default_backoff_policy)
);
103 Database const& db, IamUpdater
const& updater,
104 std::unique_ptr<TransactionRerunPolicy> rerun_policy,
105 std::unique_ptr<BackoffPolicy> backoff_policy) {
106 using RerunnablePolicy = spanner_internal::SafeTransactionRerun;
111 if (!current_policy) {
112 last_status = std::move(current_policy)
.status();
114 auto etag = current_policy
->etag();
115 auto desired = updater(
*current_policy);
116 if (!desired.has_value()) {
117 return current_policy;
119 desired->set_etag(std::move(etag));
121 if (RerunnablePolicy::IsOk(result
.status())) {
124 last_status = std::move(result)
.status();
126 if (!rerun_policy->OnFailure(last_status))
break;
127 std::this_thread::sleep_for(backoff_policy->OnCompletion());
128 }
while (!rerun_policy->IsExhausted());
132 StatusOr<
google::iam::v1::TestIamPermissionsResponse>
134 std::vector<std::string> permissions) {
141 EncryptionConfig encryption_config) {
142 auto expire_time_point =
144 if (!expire_time_point) {
145 expire_time_point = std::chrono::system_clock::time_point::max();
148 {std::move(db), std::move(backup_id),
*std::move(expire_time_point),
149 expire_time, std::move(version_time), std::move(encryption_config)}
);
154 std::chrono::system_clock::time_point expire_time) {
165 google::spanner::admin::database::v1::Backup
const& backup) {
174 std::string filter) {
175 return conn_->
ListBackups({std::move(in), std::move(filter)}
);
179 google::spanner::admin::database::v1::Backup
const& backup,
181 google::spanner::admin::database::v1::UpdateBackupRequest request;
182 request.mutable_backup()->set_name(backup.name());
183 *request.mutable_backup()->mutable_expire_time() =
185 request.mutable_update_mask()->add_paths(
"expire_time");
191 google::spanner::admin::database::v1::UpdateBackupRequest request;
192 request.mutable_backup()->set_name(backup
.FullName());
193 *request.mutable_backup()->mutable_expire_time() =
195 request.mutable_update_mask()->add_paths(
"expire_time");
200 google::spanner::admin::database::v1::Backup
const& backup,
201 std::chrono::system_clock::time_point
const& expire_time) {
209 std::chrono::system_clock::time_point
const& expire_time) {