Skip to content

Commit c5c50b0

Browse files
authored
chore: change Spanner instance admin call used by example (#10120)
Switch from `ListInstances()` to `ListInstanceConfigs()` so that we might observe the effect in the "cloud_apis" data collection.
1 parent f2921f9 commit c5c50b0

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

examples/grpc_credential_types.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ google::iam::credentials::v1::GenerateAccessTokenResponse UseAccessToken(
117117
google::cloud::spanner_admin::MakeInstanceAdminConnection(
118118
google::cloud::Options{}.set<google::cloud::GrpcCredentialOption>(
119119
credentials)));
120-
for (auto instance :
121-
admin.ListInstances(google::cloud::Project(project_id).FullName())) {
122-
if (!instance) throw std::runtime_error(instance.status().message());
123-
std::cout << "Instance: " << instance->name() << "\n";
120+
for (auto config : admin.ListInstanceConfigs(
121+
google::cloud::Project(project_id).FullName())) {
122+
if (!config) throw std::runtime_error(config.status().message());
123+
std::cout << "InstanceConfig: " << config->name() << "\n";
124124
}
125125

126126
return *std::move(token);
@@ -146,13 +146,13 @@ void UseAccessTokenUntilExpired(google::cloud::iam::IAMCredentialsClient client,
146146
google::cloud::spanner_admin::MakeInstanceAdminConnection(
147147
google::cloud::Options{}.set<google::cloud::GrpcCredentialOption>(
148148
credentials)));
149-
for (auto instance :
150-
admin.ListInstances(google::cloud::Project(project_id).FullName())) {
149+
for (auto config : admin.ListInstanceConfigs(
150+
google::cloud::Project(project_id).FullName())) {
151151
// kUnauthenticated receives special treatment, it is the error received
152152
// when the token expires.
153-
if (instance.status().code() ==
153+
if (config.status().code() ==
154154
google::cloud::StatusCode::kUnauthenticated) {
155-
std::cout << "error [" << instance.status() << "]";
155+
std::cout << "error [" << config.status() << "]";
156156
if (!expired) {
157157
std::cout << ": unexpected, but could be a race condition."
158158
<< " Trying again\n";
@@ -161,8 +161,8 @@ void UseAccessTokenUntilExpired(google::cloud::iam::IAMCredentialsClient client,
161161
std::cout << ": this is expected as the token is expired\n";
162162
return false;
163163
}
164-
if (!instance) throw std::runtime_error(instance.status().message());
165-
std::cout << "success (" << instance->name() << ")\n";
164+
if (!config) throw std::runtime_error(config.status().message());
165+
std::cout << "success (" << config->name() << ")\n";
166166
return true;
167167
}
168168
return false;

0 commit comments

Comments
 (0)