16 #include "google/cloud/internal/disable_deprecation_warnings.inc"
17 #include "google/cloud/spanner/instance_admin_client.h"
24 StatusOr<
google::spanner::admin::instance::v1::Instance>
29 future<StatusOr<
google::spanner::admin::instance::v1::Instance>>
31 google::spanner::admin::instance::v1::CreateInstanceRequest
const&
36 future<StatusOr<
google::spanner::admin::instance::v1::Instance>>
38 google::spanner::admin::instance::v1::UpdateInstanceRequest
const&
47 StatusOr<
google::spanner::admin::instance::v1::InstanceConfig>
53 std::string project_id) {
59 return conn_->
ListInstances({std::move(project_id), std::move(filter)}
);
73 Instance const& in, IamUpdater
const& updater) {
74 auto const rerun_maximum_duration = std::chrono::minutes(15);
75 auto default_rerun_policy =
76 LimitedTimeTransactionRerunPolicy(rerun_maximum_duration).clone();
78 auto const backoff_initial_delay = std::chrono::milliseconds(1000);
79 auto const backoff_maximum_delay = std::chrono::minutes(5);
80 auto const backoff_scaling = 2.0;
81 auto default_backoff_policy =
82 ExponentialBackoffPolicy(backoff_initial_delay, backoff_maximum_delay,
87 std::move(default_backoff_policy)
);
91 Instance const& in, IamUpdater
const& updater,
92 std::unique_ptr<TransactionRerunPolicy> rerun_policy,
93 std::unique_ptr<BackoffPolicy> backoff_policy) {
94 using RerunnablePolicy = spanner_internal::SafeTransactionRerun;
99 if (!current_policy) {
100 last_status = std::move(current_policy)
.status();
102 auto etag = current_policy
->etag();
103 auto desired = updater(
*current_policy);
104 if (!desired.has_value()) {
105 return current_policy;
107 desired->set_etag(std::move(etag));
109 if (RerunnablePolicy::IsOk(result
.status())) {
112 last_status = std::move(result)
.status();
114 if (!rerun_policy->OnFailure(last_status))
break;
115 std::this_thread::sleep_for(backoff_policy->OnCompletion());
116 }
while (!rerun_policy->IsExhausted());
120 StatusOr<
google::iam::v1::TestIamPermissionsResponse>
122 std::vector<std::string> permissions) {