Skip to content

Commit 0d77e69

Browse files
authored
cleanup(bigtable): store project id in InstanceAdmin (#8051)
1 parent 041f783 commit 0d77e69

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

google/cloud/bigtable/instance_admin.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "google/cloud/bigtable/version.h"
3030
#include "google/cloud/future.h"
3131
#include "google/cloud/iam_policy.h"
32+
#include "google/cloud/project.h"
3233
#include "google/cloud/status_or.h"
3334
#include <future>
3435
#include <memory>
@@ -128,7 +129,8 @@ class InstanceAdmin {
128129
*/
129130
explicit InstanceAdmin(std::shared_ptr<InstanceAdminClient> client)
130131
: client_(std::move(client)),
131-
project_name_("projects/" + project_id()),
132+
project_id_(client_->project()),
133+
project_name_(Project(project_id_).FullName()),
132134
rpc_retry_policy_prototype_(
133135
DefaultRPCRetryPolicy(internal::kBigtableInstanceAdminLimits)),
134136
rpc_backoff_policy_prototype_(
@@ -170,24 +172,24 @@ class InstanceAdmin {
170172
/// The full name (`projects/<project_id>`) of the project.
171173
std::string const& project_name() const { return project_name_; }
172174
/// The project id, i.e., `project_name()` without the `projects/` prefix.
173-
std::string const& project_id() const { return client_->project(); }
175+
std::string const& project_id() const { return project_id_; }
174176

175177
/// Return the fully qualified name of the given instance_id.
176178
std::string InstanceName(std::string const& instance_id) const {
177-
return google::cloud::bigtable::InstanceName(project_id(), instance_id);
179+
return google::cloud::bigtable::InstanceName(project_id_, instance_id);
178180
}
179181

180182
/// Return the fully qualified name of the given cluster_id in give
181183
/// instance_id.
182184
std::string ClusterName(std::string const& instance_id,
183185
std::string const& cluster_id) const {
184-
return google::cloud::bigtable::ClusterName(project_id(), instance_id,
186+
return google::cloud::bigtable::ClusterName(project_id_, instance_id,
185187
cluster_id);
186188
}
187189

188190
std::string AppProfileName(std::string const& instance_id,
189191
std::string const& profile_id) const {
190-
return google::cloud::bigtable::AppProfileName(project_id(), instance_id,
192+
return google::cloud::bigtable::AppProfileName(project_id_, instance_id,
191193
profile_id);
192194
}
193195

@@ -772,6 +774,7 @@ class InstanceAdmin {
772774
AppProfileUpdateConfig config);
773775

774776
std::shared_ptr<InstanceAdminClient> client_;
777+
std::string project_id_;
775778
std::string project_name_;
776779
std::shared_ptr<RPCRetryPolicy const> rpc_retry_policy_prototype_;
777780
std::shared_ptr<RPCBackoffPolicy const> rpc_backoff_policy_prototype_;

0 commit comments

Comments
 (0)