diff --git a/ci/abi-dumps/google_cloud_cpp_bigtable.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_bigtable.expected.abi.dump.gz
index b5f9de316e286..c63aef96d506f 100644
Binary files a/ci/abi-dumps/google_cloud_cpp_bigtable.expected.abi.dump.gz and b/ci/abi-dumps/google_cloud_cpp_bigtable.expected.abi.dump.gz differ
diff --git a/doc/v3-migration-guide.md b/doc/v3-migration-guide.md
index b2ea23f60a432..5854ca693904d 100644
--- a/doc/v3-migration-guide.md
+++ b/doc/v3-migration-guide.md
@@ -487,6 +487,122 @@ internal legacy files.
+
+Removed bigtable::AdminClient and bigtable::TableAdmin
+
+The `bigtable::AdminClient` class and `bigtable::TableAdmin` class have been
+replaced with `bigtable_admin::BigtableTableAdminClient`.
+
+**Before:**
+
+```cpp
+
+std::shared_ptr admin_client =
+ bigtable::MakeAdminClient("project-id");
+auto table_admin = std::make_unique(
+ admin_client, "instance-id");
+
+// Drop a selection of rows by key prefix.
+auto result = table_admin.DropRowByPrefix("table-id", "row-key-prefix");
+
+// Drop all rows.
+result = table_admin.DropAllRows("table-id");
+```
+
+**After:**
+
+```cpp
+#include "google/cloud/bigtable/admin/bigtable_table_admin_client.h"
+
+auto table_admin = bigtable_admin::BigtableTableAdminClient(
+ bigtable_admin::MakeBigtableAdminConnection());
+auto table_name = bigtable::TableName("project-id", "instance-id", "table-id");
+
+// Drop a selection of rows by key prefix.
+google::bigtable::admin::v2::DropRowRangeRequest drop_rows_by_prefix;
+drop_rows_by_prefix.set_name(table_name);
+drop_rows_by_prefix.set_row_key_prefix("row-key-prefix");
+auto result = table_admin.DropRowRange(drop_rows_by_prefix);
+
+// Drop all rows.
+google::bigtable::admin::v2::DropRowRangeRequest drop_all_rows;
+drop_all_rows.set_name(table_name);
+drop_all_rows.set_delete_all_data_from_table(true);
+result = table_admin.DropRowRange(drop_all_rows);
+```
+
+
+
+WaitForConsistency is now a free function
+
+With the removal of the `bigtable::TableAdmin` class, `WaitForConsistency` has
+been moved to `bigtable_admin::BigtableTableAdminClient::WaitForConsistency`.
+
+**Before:**
+
+```cpp
+
+std::shared_ptr admin_client =
+ bigtable::MakeAdminClient("project-id");
+auto table_admin = std::make_unique(
+ admin_client, "instance-id");
+
+auto token = table_admin.GenerateConsistencyToken("table-id");
+if (!token) throw std::runtime_error(token.status().message());
+auto result = table_admin.WaitForConsistency("table-id", *token);
+```
+
+**After:**
+
+```cpp
+#include "google/cloud/bigtable/admin/bigtable_table_admin_client.h"
+
+auto connection = bigtable_admin::MakeBigtableAdminConnection();
+auto table_admin = bigtable_admin::BigtableTableAdminClient(connection);
+auto table_name = bigtable::TableName("project-id", "instance-id", "table-id");
+
+auto token = table_admin.GenerateConsistencyToken(table_name);
+if (!token) throw std::runtime_error(token.status().message());
+
+google::bigtable::admin::v2::CheckConsistencyRequest wait_request;
+wait_request.set_name(table_name);
+wait_request.set_consistency_token(token->consistency_token());
+auto wait_response = table_admin.WaitForConsistency(wait_request).get();
+```
+
+
+
+
+Removed bigtable::InstanceAdminClient and bigtable::InstanceAdmin
+
+The `bigtable::InstanceAdminClient` class and `bigtable::InstanceAdmin` class
+have been replaced with `bigtable_admin::BigtableInstanceAdminClient`.
+
+**Before:**
+
+```cpp
+auto instance_admin_client = bigtable::MakeInstanceAdminClient("project-id");
+auto instance_admin =
+ std::make_unique(instance_admin_client);
+
+auto clusters = instance_admin->ListClusters();
+```
+
+**After:**
+
+```cpp
+#include "google/cloud/bigtable/admin/bigtable_instance_admin_client.h"
+
+auto instance_admin =
+ std::make_unique(
+ bigtable_admin::MakeBigtableInstanceAdminConnection());
+
+auto clusters = instance_admin->ListClusters(
+ InstanceName("project-id", "instance-id"));
+```
+
+
+
### Pubsub
diff --git a/google/cloud/bigtable/CMakeLists.txt b/google/cloud/bigtable/CMakeLists.txt
index 3e0927a0b40c7..4449a71d74515 100644
--- a/google/cloud/bigtable/CMakeLists.txt
+++ b/google/cloud/bigtable/CMakeLists.txt
@@ -105,8 +105,6 @@ add_library(
admin/internal/bigtable_table_admin_tracing_connection.h
admin/internal/bigtable_table_admin_tracing_stub.cc
admin/internal/bigtable_table_admin_tracing_stub.h
- admin_client.cc
- admin_client.h
app_profile_config.cc
app_profile_config.h
bound_query.cc
@@ -132,10 +130,6 @@ add_library(
iam_policy.h
idempotent_mutation_policy.cc
idempotent_mutation_policy.h
- instance_admin.cc
- instance_admin.h
- instance_admin_client.cc
- instance_admin_client.h
instance_config.cc
instance_config.h
instance_list_responses.h
@@ -260,8 +254,6 @@ add_library(
sql_statement.h
table.cc
table.h
- table_admin.cc
- table_admin.h
table_config.cc
table_config.h
table_resource.cc
@@ -272,9 +264,7 @@ add_library(
value.h
version.cc
version.h
- version_info.h
- wait_for_consistency.cc
- wait_for_consistency.h)
+ version_info.h)
target_link_libraries(
google_cloud_cpp_bigtable
PUBLIC absl::memory
@@ -425,7 +415,6 @@ if (BUILD_TESTING)
# List the unit tests, then setup the targets and dependencies.
set(bigtable_client_unit_tests
# cmake-format: sort
- admin_client_test.cc
app_profile_config_test.cc
async_read_stream_test.cc
bigtable_version_test.cc
@@ -442,8 +431,6 @@ if (BUILD_TESTING)
iam_binding_test.cc
iam_policy_test.cc
idempotent_mutation_policy_test.cc
- instance_admin_client_test.cc
- instance_admin_test.cc
instance_config_test.cc
instance_resource_test.cc
instance_update_config_test.cc
@@ -491,15 +478,13 @@ if (BUILD_TESTING)
rpc_backoff_policy_test.cc
rpc_retry_policy_test.cc
sql_statement_test.cc
- table_admin_test.cc
table_config_test.cc
table_resource_test.cc
table_test.cc
testing/cleanup_stale_resources_test.cc
testing/random_names_test.cc
timestamp_test.cc
- value_test.cc
- wait_for_consistency_test.cc)
+ value_test.cc)
# Export the list of unit tests so the Bazel BUILD file can pick it up.
export_list_to_bazel("bigtable_client_unit_tests.bzl"
diff --git a/google/cloud/bigtable/admin_client.cc b/google/cloud/bigtable/admin_client.cc
deleted file mode 100644
index 4bcf80c036e36..0000000000000
--- a/google/cloud/bigtable/admin_client.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2017 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/admin_client.h"
-#include "google/cloud/bigtable/internal/defaults.h"
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-std::shared_ptr MakeAdminClient(std::string project,
- Options options) {
- auto params = bigtable_internal::AdminClientParams(
- internal::DefaultTableAdminOptions(std::move(options)));
- return std::shared_ptr(
- new AdminClient(std::move(project), std::move(params)));
-}
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/admin_client.h b/google/cloud/bigtable/admin_client.h
deleted file mode 100644
index 9f8dd1b5b9aab..0000000000000
--- a/google/cloud/bigtable/admin_client.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2017 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H
-#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H
-
-#include "google/cloud/bigtable/admin/bigtable_table_admin_connection.h"
-#include "google/cloud/bigtable/internal/admin_client_params.h"
-#include "google/cloud/bigtable/version.h"
-#include "google/cloud/grpc_options.h"
-#include "google/cloud/options.h"
-#include
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-/**
- * Creates a `bigtable_admin::BigtableTableAdminConnection` and a
- * `CompletionQueue` for `bigtable::TableAdmin` to use.
- *
- * This class is used to initiate a connection to the Cloud Bigtable Table
- * Admin service. It is maintained only for backwards compatibility.
- *
- * @note Please prefer using `bigtable_admin::BigtableTableAdminConnection` to
- * configure `bigtable_admin::BigtableTableAdminClient`, instead of using
- * this class to configure `bigtable::TableAdmin`.
- */
-class AdminClient final {
- public:
- /// The project id that this AdminClient works on.
- std::string const& project() { return project_; };
-
- private:
- friend class TableAdmin;
- friend std::shared_ptr MakeAdminClient(std::string, Options);
-
- AdminClient(std::string project, bigtable_internal::AdminClientParams params)
- : project_(std::move(project)),
- cq_(params.options.get()),
- background_threads_(std::move(params.background_threads)),
- connection_(bigtable_admin::MakeBigtableTableAdminConnection(
- std::move(params.options))) {}
-
- std::string project_;
- CompletionQueue cq_;
- std::shared_ptr background_threads_;
- std::shared_ptr connection_;
-};
-
-/// Create a new table admin client configured via @p options.
-std::shared_ptr MakeAdminClient(std::string project,
- Options options = {});
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
-
-#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ADMIN_CLIENT_H
diff --git a/google/cloud/bigtable/admin_client_test.cc b/google/cloud/bigtable/admin_client_test.cc
deleted file mode 100644
index d723f8a64ff1b..0000000000000
--- a/google/cloud/bigtable/admin_client_test.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2017 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/admin_client.h"
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-namespace {
-
-TEST(AdminClientTest, MakeClient) {
- auto admin_client = MakeAdminClient("test-project");
- ASSERT_TRUE(admin_client);
- EXPECT_EQ("test-project", admin_client->project());
-}
-
-} // namespace
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/bigtable_client_unit_tests.bzl b/google/cloud/bigtable/bigtable_client_unit_tests.bzl
index 471fcefdadcd3..6c95291b749a2 100644
--- a/google/cloud/bigtable/bigtable_client_unit_tests.bzl
+++ b/google/cloud/bigtable/bigtable_client_unit_tests.bzl
@@ -17,7 +17,6 @@
"""Automatically generated unit tests list - DO NOT EDIT."""
bigtable_client_unit_tests = [
- "admin_client_test.cc",
"app_profile_config_test.cc",
"async_read_stream_test.cc",
"bigtable_version_test.cc",
@@ -34,8 +33,6 @@ bigtable_client_unit_tests = [
"iam_binding_test.cc",
"iam_policy_test.cc",
"idempotent_mutation_policy_test.cc",
- "instance_admin_client_test.cc",
- "instance_admin_test.cc",
"instance_config_test.cc",
"instance_resource_test.cc",
"instance_update_config_test.cc",
@@ -83,7 +80,6 @@ bigtable_client_unit_tests = [
"rpc_backoff_policy_test.cc",
"rpc_retry_policy_test.cc",
"sql_statement_test.cc",
- "table_admin_test.cc",
"table_config_test.cc",
"table_resource_test.cc",
"table_test.cc",
@@ -91,5 +87,4 @@ bigtable_client_unit_tests = [
"testing/random_names_test.cc",
"timestamp_test.cc",
"value_test.cc",
- "wait_for_consistency_test.cc",
]
diff --git a/google/cloud/bigtable/ci/run_integration_tests_emulator_bazel.sh b/google/cloud/bigtable/ci/run_integration_tests_emulator_bazel.sh
index 966435e0bb52e..ba218743f7e64 100755
--- a/google/cloud/bigtable/ci/run_integration_tests_emulator_bazel.sh
+++ b/google/cloud/bigtable/ci/run_integration_tests_emulator_bazel.sh
@@ -59,8 +59,8 @@ source module /google/cloud/bigtable/tools/run_emulator_utils.sh
production_only_targets=(
"//google/cloud/bigtable/examples:bigtable_table_admin_backup_snippets"
"//google/cloud/bigtable/examples:table_admin_iam_policy_snippets"
- "//google/cloud/bigtable/tests:admin_backup_integration_test"
- "//google/cloud/bigtable/tests:admin_iam_policy_integration_test"
+ "//google/cloud/bigtable/tests:table_admin_backup_integration_test"
+ "//google/cloud/bigtable/tests:table_admin_iam_policy_integration_test"
)
# Coverage builds are more subject to flakiness, as we must explicitly disable
diff --git a/google/cloud/bigtable/examples/table_admin_snippets.cc b/google/cloud/bigtable/examples/table_admin_snippets.cc
index 5a8aa79604772..6e6499a19d647 100644
--- a/google/cloud/bigtable/examples/table_admin_snippets.cc
+++ b/google/cloud/bigtable/examples/table_admin_snippets.cc
@@ -14,10 +14,8 @@
#include "google/cloud/bigtable/admin/bigtable_table_admin_client.h"
#include "google/cloud/bigtable/examples/bigtable_examples_common.h"
-#include "google/cloud/bigtable/table_admin.h"
#include "google/cloud/bigtable/testing/cleanup_stale_resources.h"
#include "google/cloud/bigtable/testing/random_names.h"
-#include "google/cloud/bigtable/wait_for_consistency.h"
#include "google/cloud/internal/getenv.h"
#include "google/cloud/log.h"
#include
diff --git a/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl b/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl
index 3bc7e814093b8..2ecc66c6fd37e 100644
--- a/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl
+++ b/google/cloud/bigtable/google_cloud_cpp_bigtable.bzl
@@ -45,7 +45,6 @@ google_cloud_cpp_bigtable_hdrs = [
"admin/internal/bigtable_table_admin_stub_factory.h",
"admin/internal/bigtable_table_admin_tracing_connection.h",
"admin/internal/bigtable_table_admin_tracing_stub.h",
- "admin_client.h",
"app_profile_config.h",
"bound_query.h",
"bytes.h",
@@ -61,8 +60,6 @@ google_cloud_cpp_bigtable_hdrs = [
"iam_binding.h",
"iam_policy.h",
"idempotent_mutation_policy.h",
- "instance_admin.h",
- "instance_admin_client.h",
"instance_config.h",
"instance_list_responses.h",
"instance_resource.h",
@@ -135,14 +132,12 @@ google_cloud_cpp_bigtable_hdrs = [
"rpc_retry_policy.h",
"sql_statement.h",
"table.h",
- "table_admin.h",
"table_config.h",
"table_resource.h",
"timestamp.h",
"value.h",
"version.h",
"version_info.h",
- "wait_for_consistency.h",
]
google_cloud_cpp_bigtable_srcs = [
@@ -171,7 +166,6 @@ google_cloud_cpp_bigtable_srcs = [
"admin/internal/bigtable_table_admin_stub_factory.cc",
"admin/internal/bigtable_table_admin_tracing_connection.cc",
"admin/internal/bigtable_table_admin_tracing_stub.cc",
- "admin_client.cc",
"app_profile_config.cc",
"bound_query.cc",
"bytes.cc",
@@ -182,8 +176,6 @@ google_cloud_cpp_bigtable_srcs = [
"iam_binding.cc",
"iam_policy.cc",
"idempotent_mutation_policy.cc",
- "instance_admin.cc",
- "instance_admin_client.cc",
"instance_config.cc",
"instance_resource.cc",
"instance_update_config.cc",
@@ -236,11 +228,9 @@ google_cloud_cpp_bigtable_srcs = [
"rpc_retry_policy.cc",
"sql_statement.cc",
"table.cc",
- "table_admin.cc",
"table_config.cc",
"table_resource.cc",
"timestamp.cc",
"value.cc",
"version.cc",
- "wait_for_consistency.cc",
]
diff --git a/google/cloud/bigtable/instance_admin.cc b/google/cloud/bigtable/instance_admin.cc
deleted file mode 100644
index b5a283c6355e2..0000000000000
--- a/google/cloud/bigtable/instance_admin.cc
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/instance_admin.h"
-#include "google/cloud/location.h"
-#include
-#include
-#include
-
-namespace btadmin = ::google::bigtable::admin::v2;
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-static_assert(std::is_copy_assignable::value,
- "bigtable::InstanceAdmin must be CopyAssignable");
-
-StatusOr InstanceAdmin::ListInstances() {
- google::cloud::internal::OptionsSpan span(options_);
- InstanceList result;
-
- // Build the RPC request, try to minimize copying.
- btadmin::ListInstancesRequest request;
- request.set_parent(project_name());
- auto sor = connection_->ListInstances(request);
- if (!sor) return std::move(sor).status();
- auto response = *std::move(sor);
- auto& instances = *response.mutable_instances();
- std::move(instances.begin(), instances.end(),
- std::back_inserter(result.instances));
- auto& failed_locations = *response.mutable_failed_locations();
- std::move(failed_locations.begin(), failed_locations.end(),
- std::back_inserter(result.failed_locations));
- return result;
-}
-
-future> InstanceAdmin::CreateInstance(
- InstanceConfig instance_config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(instance_config).as_proto();
- request.set_parent(project_name());
- for (auto& kv : *request.mutable_clusters()) {
- kv.second.set_location(
- Location(project_id(), kv.second.location()).FullName());
- }
- return connection_->CreateInstance(request);
-}
-
-future> InstanceAdmin::CreateCluster(
- ClusterConfig cluster_config, std::string const& instance_id,
- std::string const& cluster_id) {
- google::cloud::internal::OptionsSpan span(options_);
- auto cluster = std::move(cluster_config).as_proto();
- cluster.set_location(Location(project_id(), cluster.location()).FullName());
- btadmin::CreateClusterRequest request;
- request.mutable_cluster()->Swap(&cluster);
- request.set_parent(InstanceName(instance_id));
- request.set_cluster_id(cluster_id);
- return connection_->CreateCluster(request);
-}
-
-future>
-InstanceAdmin::UpdateInstance(InstanceUpdateConfig instance_update_config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(instance_update_config).as_proto();
- return connection_->PartialUpdateInstance(request);
-}
-
-StatusOr InstanceAdmin::GetInstance(
- std::string const& instance_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GetInstanceRequest request;
- request.set_name(InstanceName(instance_id));
- return connection_->GetInstance(request);
-}
-
-Status InstanceAdmin::DeleteInstance(std::string const& instance_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteInstanceRequest request;
- request.set_name(InstanceName(instance_id));
- return connection_->DeleteInstance(request);
-}
-
-StatusOr InstanceAdmin::GetCluster(
- std::string const& instance_id, std::string const& cluster_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GetClusterRequest request;
- request.set_name(ClusterName(instance_id, cluster_id));
- return connection_->GetCluster(request);
-}
-
-StatusOr InstanceAdmin::ListClusters() {
- return ListClusters("-");
-}
-
-StatusOr InstanceAdmin::ListClusters(
- std::string const& instance_id) {
- google::cloud::internal::OptionsSpan span(options_);
- ClusterList result;
-
- btadmin::ListClustersRequest request;
- request.set_parent(InstanceName(instance_id));
- auto sor = connection_->ListClusters(request);
- if (!sor) return std::move(sor).status();
- auto response = *std::move(sor);
- auto& clusters = *response.mutable_clusters();
- std::move(clusters.begin(), clusters.end(),
- std::back_inserter(result.clusters));
- auto& failed_locations = *response.mutable_failed_locations();
- std::move(failed_locations.begin(), failed_locations.end(),
- std::back_inserter(result.failed_locations));
- return result;
-}
-
-future>
-InstanceAdmin::UpdateCluster(ClusterConfig cluster_config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(cluster_config).as_proto();
- return connection_->UpdateCluster(request);
-}
-
-Status InstanceAdmin::DeleteCluster(std::string const& instance_id,
- std::string const& cluster_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteClusterRequest request;
- request.set_name(ClusterName(instance_id, cluster_id));
- return connection_->DeleteCluster(request);
-}
-
-StatusOr InstanceAdmin::CreateAppProfile(
- std::string const& instance_id, AppProfileConfig config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(config).as_proto();
- request.set_parent(InstanceName(instance_id));
- return connection_->CreateAppProfile(request);
-}
-
-StatusOr InstanceAdmin::GetAppProfile(
- std::string const& instance_id, std::string const& profile_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GetAppProfileRequest request;
- request.set_name(AppProfileName(instance_id, profile_id));
- return connection_->GetAppProfile(request);
-}
-
-future> InstanceAdmin::UpdateAppProfile(
- std::string const& instance_id, std::string const& profile_id,
- AppProfileUpdateConfig config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(config).as_proto();
- request.mutable_app_profile()->set_name(
- AppProfileName(instance_id, profile_id));
- return connection_->UpdateAppProfile(request);
-}
-
-StatusOr> InstanceAdmin::ListAppProfiles(
- std::string const& instance_id) {
- google::cloud::internal::OptionsSpan span(options_);
- std::vector result;
-
- btadmin::ListAppProfilesRequest request;
- request.set_parent(InstanceName(instance_id));
- auto sr = connection_->ListAppProfiles(request);
- for (auto& ap : sr) {
- if (!ap) return std::move(ap).status();
- result.emplace_back(*std::move(ap));
- }
- return result;
-}
-
-Status InstanceAdmin::DeleteAppProfile(std::string const& instance_id,
- std::string const& profile_id,
- bool ignore_warnings) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteAppProfileRequest request;
- request.set_name(AppProfileName(instance_id, profile_id));
- request.set_ignore_warnings(ignore_warnings);
- return connection_->DeleteAppProfile(request);
-}
-
-StatusOr InstanceAdmin::GetNativeIamPolicy(
- std::string const& instance_id) {
- google::cloud::internal::OptionsSpan span(options_);
- google::iam::v1::GetIamPolicyRequest request;
- request.set_resource(InstanceName(instance_id));
- return connection_->GetIamPolicy(request);
-}
-
-StatusOr InstanceAdmin::SetIamPolicy(
- std::string const& instance_id, google::iam::v1::Policy const& iam_policy) {
- google::cloud::internal::OptionsSpan span(options_);
- google::iam::v1::SetIamPolicyRequest request;
- request.set_resource(InstanceName(instance_id));
- *request.mutable_policy() = iam_policy;
- return connection_->SetIamPolicy(request);
-}
-
-StatusOr> InstanceAdmin::TestIamPermissions(
- std::string const& instance_id,
- std::vector const& permissions) {
- google::cloud::internal::OptionsSpan span(options_);
- google::iam::v1::TestIamPermissionsRequest request;
- request.set_resource(InstanceName(instance_id));
- for (auto const& permission : permissions) {
- request.add_permissions(permission);
- }
- auto sor = connection_->TestIamPermissions(request);
- if (!sor) return std::move(sor).status();
- auto response = *std::move(sor);
- std::vector result;
- auto& ps = *response.mutable_permissions();
- std::move(ps.begin(), ps.end(), std::back_inserter(result));
- return result;
-}
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/instance_admin.h b/google/cloud/bigtable/instance_admin.h
deleted file mode 100644
index e7f218261fd07..0000000000000
--- a/google/cloud/bigtable/instance_admin.h
+++ /dev/null
@@ -1,732 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_H
-#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_H
-
-#include "google/cloud/bigtable/admin/bigtable_instance_admin_connection.h"
-#include "google/cloud/bigtable/admin/bigtable_instance_admin_options.h"
-#include "google/cloud/bigtable/app_profile_config.h"
-#include "google/cloud/bigtable/cluster_config.h"
-#include "google/cloud/bigtable/cluster_list_responses.h"
-#include "google/cloud/bigtable/completion_queue.h"
-#include "google/cloud/bigtable/iam_policy.h"
-#include "google/cloud/bigtable/instance_admin_client.h"
-#include "google/cloud/bigtable/instance_config.h"
-#include "google/cloud/bigtable/instance_list_responses.h"
-#include "google/cloud/bigtable/instance_update_config.h"
-#include "google/cloud/bigtable/internal/convert_policies.h"
-#include "google/cloud/bigtable/polling_policy.h"
-#include "google/cloud/bigtable/resource_names.h"
-#include "google/cloud/bigtable/version.h"
-#include "google/cloud/future.h"
-#include "google/cloud/project.h"
-#include "google/cloud/status_or.h"
-#include
-#include
-#include
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable_internal {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-class InstanceAdminTester;
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable_internal
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-/**
- * Implements the APIs to administer Cloud Bigtable instances.
- *
- * @par Thread-safety
- * 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 concurrently on the same
- * instance of this class is not guaranteed to work.
- *
- * @par Cost
- * Creating a new object of type `InstanceAdmin` is comparable to creating a few
- * objects of type `std::string` or a few objects of type
- * `std::shared_ptr`. The class represents a shallow handle to a remote
- * object.
- *
- * @par Error Handling
- * This class uses `StatusOr` to report errors. When an operation fails to
- * perform its work the returned `StatusOr` contains the error details. If
- * the `ok()` member function in the `StatusOr` returns `true` then it
- * contains the expected result. Operations that do not return a value simply
- * return a `google::cloud::Status` indicating success or the details of the
- * error Please consult the [`StatusOr`
- * documentation](#google::cloud::StatusOr) for more details.
- *
- * @code
- * namespace cbt = google::cloud::bigtable;
- * namespace btadmin = google::bigtable::admin::v2;
- * cbt::InstanceAdmin admin = ...;
- * google::cloud::StatusOr instance = admin.GetInstance(...);
- *
- * if (!instance) {
- * std::cerr << "Error fetching instance\n";
- * return;
- * }
- *
- * // Use `instance` as a smart pointer here, e.g.:
- * std::cout << "The full instance name is " << instance->name() << "\n";
- * @endcode
- *
- * In addition, the @ref index "main page" contains examples using `StatusOr`
- * to handle errors.
- *
- * @par Retry, Backoff, and Idempotency Policies
- * The library automatically retries requests that fail with transient errors,
- * and uses [truncated exponential backoff][backoff-link] to backoff between
- * retries. The default policies are to continue retrying for up to 10 minutes.
- * On each transient failure the backoff period is doubled, starting with an
- * initial backoff of 100 milliseconds. The backoff period growth is truncated
- * at 60 seconds. The default idempotency policy is to only retry idempotent
- * operations. Note that most operations that change state are **not**
- * idempotent.
- *
- * The application can override these policies when constructing objects of this
- * class. The documentation for the constructors show examples of this in
- * action.
- *
- * [backoff-link]: https://cloud.google.com/storage/docs/exponential-backoff
- *
- * @see https://cloud.google.com/bigtable/ for an overview of Cloud Bigtable.
- *
- * @see https://cloud.google.com/bigtable/docs/overview for an overview of the
- * Cloud Bigtable data model.
- *
- * @see https://cloud.google.com/bigtable/docs/instances-clusters-nodes for an
- * introduction of the main APIs into Cloud Bigtable.
- *
- * @see https://cloud.google.com/bigtable/docs/reference/service-apis-overview
- * for an overview of the underlying Cloud Bigtable API.
- *
- * @see #google::cloud::StatusOr for a description of the error reporting class
- * used by this library.
- *
- * @see `LimitedTimeRetryPolicy` and `LimitedErrorCountRetryPolicy` for
- * alternative retry policies.
- *
- * @see `ExponentialBackoffPolicy` to configure different parameters for the
- * exponential backoff policy.
- *
- * @see `SafeIdempotentMutationPolicy` and `AlwaysRetryMutationPolicy` for
- * alternative idempotency policies.
- */
-class InstanceAdmin {
- public:
- explicit InstanceAdmin(
- std::shared_ptr
- connection,
- std::string project)
- : connection_(std::move(connection)),
- project_id_(std::move(project)),
- project_name_(Project(project_id_).FullName()),
- retry_prototype_(
- DefaultRPCRetryPolicy(internal::kBigtableInstanceAdminLimits)),
- backoff_prototype_(
- DefaultRPCBackoffPolicy(internal::kBigtableInstanceAdminLimits)),
- polling_prototype_(
- DefaultPollingPolicy(internal::kBigtableInstanceAdminLimits)),
- options_(google::cloud::internal::MergeOptions(
- bigtable_internal::MakeInstanceAdminOptions(
- retry_prototype_, backoff_prototype_, polling_prototype_),
- connection_->options())) {}
-
- /**
- * @param client the interface to create grpc stubs, report errors, etc.
- */
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- explicit InstanceAdmin(std::shared_ptr client)
- : InstanceAdmin(client->connection_, client->project()) {}
-
- /**
- * Create a new InstanceAdmin using explicit policies to handle RPC errors.
- *
- * @param client the interface to create grpc stubs, report errors, etc.
- * @param policies the set of policy overrides for this object.
- * @tparam Policies the types of the policies to override, the types must
- * derive from one of the following types:
- * - `RPCBackoffPolicy` how to backoff from a failed RPC. Currently only
- * `ExponentialBackoffPolicy` is implemented. You can also create your
- * own policies that backoff using a different algorithm.
- * - `RPCRetryPolicy` for how long to retry failed RPCs. Use
- * `LimitedErrorCountRetryPolicy` to limit the number of failures
- * allowed. Use `LimitedTimeRetryPolicy` to bound the time for any
- * request. You can also create your own policies that combine time and
- * error counts.
- * - `PollingPolicy` for how long will the class wait for
- * `google.longrunning.Operation` to complete. This class combines both
- * the backoff policy for checking long running operations and the
- * retry policy.
- *
- * @see GenericPollingPolicy, ExponentialBackoffPolicy,
- * LimitedErrorCountRetryPolicy, LimitedTimeRetryPolicy.
- */
- template
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- explicit InstanceAdmin(std::shared_ptr client,
- Policies&&... policies)
- : connection_(client->connection_),
- project_id_(client->project()),
- project_name_(Project(project_id_).FullName()),
- retry_prototype_(
- DefaultRPCRetryPolicy(internal::kBigtableInstanceAdminLimits)),
- backoff_prototype_(
- DefaultRPCBackoffPolicy(internal::kBigtableInstanceAdminLimits)),
- polling_prototype_(
- DefaultPollingPolicy(internal::kBigtableInstanceAdminLimits)) {
- ChangePolicies(std::forward(policies)...);
- options_ = google::cloud::internal::MergeOptions(
- bigtable_internal::MakeInstanceAdminOptions(
- retry_prototype_, backoff_prototype_, polling_prototype_),
- connection_->options());
- }
-
- /// The full name (`projects/`) of the project.
- std::string const& project_name() const { return project_name_; }
- /// The project id, i.e., `project_name()` without the `projects/` prefix.
- std::string const& project_id() const { return project_id_; }
-
- /**
- * Returns an InstanceAdmin that reuses the connection and configuration of
- * this InstanceAdmin, but with a different resource name.
- */
- InstanceAdmin WithNewTarget(std::string project_id) const {
- auto admin = *this;
- admin.project_id_ = std::move(project_id);
- admin.project_name_ = Project(admin.project_id_).FullName();
- return admin;
- }
-
- /// Return the fully qualified name of the given instance_id.
- std::string InstanceName(std::string const& instance_id) const {
- return google::cloud::bigtable::InstanceName(project_id_, instance_id);
- }
-
- /// Return the fully qualified name of the given cluster_id in give
- /// instance_id.
- std::string ClusterName(std::string const& instance_id,
- std::string const& cluster_id) const {
- return google::cloud::bigtable::ClusterName(project_id_, instance_id,
- cluster_id);
- }
-
- std::string AppProfileName(std::string const& instance_id,
- std::string const& profile_id) const {
- return google::cloud::bigtable::AppProfileName(project_id_, instance_id,
- profile_id);
- }
-
- /**
- * Create a new instance of Cloud Bigtable.
- *
- * @warning Note that this is operation can take seconds or minutes to
- * complete. The application may prefer to perform other work while waiting
- * for this operation.
- *
- * @param instance_config a description of the new instance to be created.
- * instance_id and a display_name parameters must be set in instance_config,
- * - instance_id : must be between 6 and 33 characters.
- * - display_name : must be between 4 and 30 characters.
- * @return a future that becomes satisfied when (a) the operation has
- * completed successfully, in which case it returns a proto with the
- * Instance details, (b) the operation has failed, in which case the future
- * contains an `google::cloud::Status` with the details of the failure, or
- * (c) the state of the operation is unknown after the time allocated by the
- * retry policies has expired, in which case the future contains the last
- * error status.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc create instance
- */
- future> CreateInstance(
- InstanceConfig instance_config);
-
- /**
- * Create a new Cluster of Cloud Bigtable.
- *
- * @param cluster_config a description of the new cluster to be created.
- * @param instance_id the id of the instance in the project
- * @param cluster_id the id of the cluster in the project that needs to be
- * created. It must be between 6 and 30 characters.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc create cluster
- */
- future> CreateCluster(
- ClusterConfig cluster_config, std::string const& instance_id,
- std::string const& cluster_id);
-
- /**
- * Update an existing instance of Cloud Bigtable.
- *
- * @warning Note that this is operation can take seconds or minutes to
- * complete. The application may prefer to perform other work while waiting
- * for this operation.
- *
- * @param instance_update_config config with modified instance.
- * @return a future that becomes satisfied when (a) the operation has
- * completed successfully, in which case it returns a proto with the
- * Instance details, (b) the operation has failed, in which case the future
- * contains an exception (typically `bigtable::GrpcError`) with the details
- * of the failure, or (c) the state of the operation is unknown after the
- * time allocated by the retry policies has expired, in which case the
- * future contains an exception of type `bigtable::PollTimeout`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc update instance
- */
- future> UpdateInstance(
- InstanceUpdateConfig instance_update_config);
-
- /**
- * Obtain the list of instances in the project.
- *
- * @note In some circumstances Cloud Bigtable may be unable to obtain the full
- * list of instances, typically because some transient failure has made
- * specific zones unavailable. In this cases the service returns a separate
- * list of `failed_locations` that represent the unavailable zones.
- * Applications may want to retry the operation after the transient
- * conditions have cleared.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc list instances
- */
- StatusOr ListInstances();
-
- /**
- * Return the details of @p instance_id.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc get instance
- */
- StatusOr GetInstance(
- std::string const& instance_id);
-
- /**
- * Deletes the instances in the project.
- *
- * @param instance_id the id of the instance in the project that needs to be
- * deleted
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc delete instance
- */
- Status DeleteInstance(std::string const& instance_id);
-
- /**
- * Obtain the list of clusters in an instance.
- *
- * @note In some circumstances Cloud Bigtable may be unable to obtain the full
- * list of clusters, typically because some transient failure has made
- * specific zones unavailable. In this cases the service returns a separate
- * list of `failed_locations` that represent the unavailable zones.
- * Applications may want to retry the operation after the transient
- * conditions have cleared.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc list clusters
- */
- StatusOr ListClusters();
-
- /**
- * Obtain the list of clusters in an instance.
- *
- * @note In some circumstances Cloud Bigtable may be unable to obtain the full
- * list of clusters, typically because some transient failure has made
- * specific zones unavailable. In this cases the service returns a separate
- * list of `failed_locations` that represent the unavailable zones.
- * Applications may want to retry the operation after the transient
- * conditions have cleared.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc list clusters
- */
- StatusOr ListClusters(std::string const& instance_id);
-
- /**
- * Update an existing cluster of Cloud Bigtable.
- *
- * @warning Note that this is operation can take seconds or minutes to
- * complete. The application may prefer to perform other work while waiting
- * for this operation.
- *
- * @param cluster_config cluster with updated values.
- * @return a future that becomes satisfied when (a) the operation has
- * completed successfully, in which case it returns a proto with the
- * Instance details, (b) the operation has failed, in which case the future
- * contains an exception (typically `bigtable::GrpcError`) with the details
- * of the failure, or (c) the state of the operation is unknown after the
- * time allocated by the retry policies has expired, in which case the
- * future contains an exception of type `bigtable::PollTimeout`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc update cluster
- */
- future> UpdateCluster(
- ClusterConfig cluster_config);
-
- /**
- * Deletes the specified cluster of an instance in the project.
- *
- * @param instance_id the id of the instance in the project
- * @param cluster_id the id of the cluster in the project that needs to be
- * deleted
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc delete cluster
- */
- Status DeleteCluster(std::string const& instance_id,
- std::string const& cluster_id);
-
- /**
- * Gets the specified cluster of an instance in the project.
- *
- * @param instance_id the id of the instance in the project
- * @param cluster_id the id of the cluster in the project that needs to be
- * deleted
- * @return a Cluster for given instance_id and cluster_id.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc get cluster
- */
- StatusOr GetCluster(
- std::string const& instance_id, std::string const& cluster_id);
-
- /**
- * Create a new application profile.
- *
- * @param instance_id the instance for the new application profile.
- * @param config the configuration for the new application profile.
- * @return The proto describing the new application profile.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Multi-cluster Routing Example
- * @snippet bigtable_instance_admin_snippets.cc create app profile
- *
- * @par Single Cluster Routing Example
- * @snippet bigtable_instance_admin_snippets.cc create app profile cluster
- */
- StatusOr CreateAppProfile(
- std::string const& instance_id, AppProfileConfig config);
-
- /**
- * Fetch the detailed information about an existing application profile.
- *
- * @param instance_id the instance to look the profile in.
- * @param profile_id the id of the profile within that instance.
- * @return The proto describing the application profile.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc get app profile
- */
- StatusOr GetAppProfile(
- std::string const& instance_id, std::string const& profile_id);
-
- /**
- * Updates an existing application profile.
- *
- * @param instance_id the instance for the new application profile.
- * @param profile_id the id (not the full name) of the profile to update.
- * @param config the configuration for the new application profile.
- * @return The proto describing the new application profile.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Change Description Example
- * @snippet bigtable_instance_admin_snippets.cc update app profile description
- *
- * @par Change Routing to Any Cluster Example
- * @snippet bigtable_instance_admin_snippets.cc update app profile routing any
- *
- * @par Change Routing to a Specific Cluster Example
- * @snippet bigtable_instance_admin_snippets.cc update app profile routing
- */
- future> UpdateAppProfile(
- std::string const& instance_id, std::string const& profile_id,
- AppProfileUpdateConfig config);
-
- /**
- * List the application profiles in an instance.
- *
- * @param instance_id the instance to list the profiles for.
- * @return a std::vector with the protos describing any profiles.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc list app profiles
- */
- StatusOr>
- ListAppProfiles(std::string const& instance_id);
-
- /**
- * Delete an existing application profile.
- *
- * @param instance_id the instance to look the profile in.
- * @param profile_id the id of the profile within that instance.
- * @param ignore_warnings if true, ignore safety checks when deleting the
- * application profile. This value is to to `true` by default. Passing
- * `false` causes this function to fail even when no operations are
- * pending.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc delete app profile
- */
- Status DeleteAppProfile(std::string const& instance_id,
- std::string const& profile_id,
- bool ignore_warnings = true);
-
- /**
- * Gets the native policy for @p instance_id.
- *
- * @param instance_id the instance to query.
- * @return google::iam::v1::Policy the full IAM policy for the instance.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc get native iam policy
- */
- StatusOr GetNativeIamPolicy(
- std::string const& instance_id);
-
- /**
- * Sets the IAM policy for an instance.
- *
- * @param instance_id which instance to set the IAM policy for.
- * @param iam_policy google::iam::v1::Policy object containing role and
- * members.
- * @return google::iam::v1::Policy the current IAM policy for the instance.
- *
- * @warning ETags are currently not used by Cloud Bigtable.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc set native iam policy
- */
- StatusOr SetIamPolicy(
- std::string const& instance_id,
- google::iam::v1::Policy const& iam_policy);
-
- /**
- * Returns a permission set that the caller has on the specified instance.
- *
- * @param instance_id the ID of the instance to query.
- * @param permissions set of permissions to check for the resource.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_instance_admin_snippets.cc test iam permissions
- *
- * @see https://cloud.google.com/bigtable/docs/access-control for a list of
- * valid permissions on Google Cloud Bigtable.
- */
- StatusOr> TestIamPermissions(
- std::string const& instance_id,
- std::vector const& permissions);
-
- private:
- friend class bigtable_internal::InstanceAdminTester;
-
- ///@{
- /// @name Helper functions to implement constructors with changed policies.
- void ChangePolicy(RPCRetryPolicy const& policy) {
- retry_prototype_ = policy.clone();
- }
-
- void ChangePolicy(RPCBackoffPolicy const& policy) {
- backoff_prototype_ = policy.clone();
- }
-
- void ChangePolicy(PollingPolicy const& policy) {
- polling_prototype_ = policy.clone();
- }
-
- template
- void ChangePolicies(Policy&& policy, Policies&&... policies) {
- ChangePolicy(policy);
- ChangePolicies(std::forward(policies)...);
- }
- void ChangePolicies() {}
- ///@}
-
- std::shared_ptr connection_;
- std::string project_id_;
- std::string project_name_;
- ///@{
- /// These prototypes are only used as temporary storage during construction of
- /// the class, where they are consolidated as common policies in `options_`.
- std::shared_ptr retry_prototype_;
- std::shared_ptr backoff_prototype_;
- std::shared_ptr polling_prototype_;
- ///}
- Options options_;
-};
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
-
-#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_H
diff --git a/google/cloud/bigtable/instance_admin_client.cc b/google/cloud/bigtable/instance_admin_client.cc
deleted file mode 100644
index 1309858e2d537..0000000000000
--- a/google/cloud/bigtable/instance_admin_client.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/instance_admin_client.h"
-#include "google/cloud/bigtable/internal/defaults.h"
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-std::shared_ptr MakeInstanceAdminClient(
- std::string project, Options options) {
- options = internal::DefaultInstanceAdminOptions(std::move(options));
- return std::shared_ptr(
- new InstanceAdminClient(std::move(project), std::move(options)));
-}
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/instance_admin_client.h b/google/cloud/bigtable/instance_admin_client.h
deleted file mode 100644
index e5c9e1acfb394..0000000000000
--- a/google/cloud/bigtable/instance_admin_client.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_CLIENT_H
-#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_CLIENT_H
-
-#include "google/cloud/bigtable/admin/bigtable_instance_admin_connection.h"
-#include "google/cloud/bigtable/version.h"
-#include
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-/**
- * Creates a `bigtable_admin::BigtableInstanceAdminConnection` for
- * `bigtable::InstanceAdmin` to use.
- *
- * This class is used to initiate a connection to the Cloud Bigtable Instance
- * Admin service. It is maintained only for backwards compatibility.
- *
- * @deprecated Please use `bigtable_admin::BigtableInstanceAdminConnection` to
- * configure `bigtable_admin::BigtableInstanceAdminClient`, instead of using
- * this class to configure `bigtable::InstanceAdmin`.
- */
-class InstanceAdminClient final {
- public:
- virtual ~InstanceAdminClient() = default;
-
- /// The project id that this AdminClient works on.
- virtual std::string const& project() { return project_; }
-
- private:
- friend class InstanceAdmin;
- friend std::shared_ptr MakeInstanceAdminClient(
- std::string, Options);
-
- InstanceAdminClient(std::string project, Options options)
- : project_(std::move(project)),
- connection_(bigtable_admin::MakeBigtableInstanceAdminConnection(
- std::move(options))) {}
-
- std::string project_;
- std::shared_ptr connection_;
-};
-
-/// Create a new instance admin client configured via @p options.
-std::shared_ptr MakeInstanceAdminClient(
- std::string project, Options options = {});
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
-
-#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INSTANCE_ADMIN_CLIENT_H
diff --git a/google/cloud/bigtable/instance_admin_client_test.cc b/google/cloud/bigtable/instance_admin_client_test.cc
deleted file mode 100644
index a6cff0f75240a..0000000000000
--- a/google/cloud/bigtable/instance_admin_client_test.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/instance_admin_client.h"
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-namespace {
-
-TEST(InstanceAdminClientTest, MakeClient) {
- auto admin_client = MakeInstanceAdminClient("test-project");
- ASSERT_TRUE(admin_client);
- EXPECT_EQ("test-project", admin_client->project());
-}
-
-} // namespace
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/instance_admin_test.cc b/google/cloud/bigtable/instance_admin_test.cc
deleted file mode 100644
index 433eb80c5dc89..0000000000000
--- a/google/cloud/bigtable/instance_admin_test.cc
+++ /dev/null
@@ -1,694 +0,0 @@
-// Copyright 2022 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/instance_admin.h"
-#include "google/cloud/bigtable/admin/mocks/mock_bigtable_instance_admin_connection.h"
-#include "google/cloud/bigtable/testing/mock_policies.h"
-#include "google/cloud/grpc_options.h"
-#include "google/cloud/location.h"
-#include "google/cloud/project.h"
-#include "google/cloud/testing_util/status_matchers.h"
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable_internal {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-
-// Helper class for checking that the legacy API still functions correctly
-class InstanceAdminTester {
- public:
- static std::shared_ptr
- Connection(bigtable::InstanceAdmin const& admin) {
- return admin.connection_;
- }
-
- static ::google::cloud::Options Options(
- bigtable::InstanceAdmin const& admin) {
- return admin.options_;
- }
-};
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable_internal
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-namespace {
-
-namespace btadmin = ::google::bigtable::admin::v2;
-namespace iamproto = ::google::iam::v1;
-
-using ::google::cloud::bigtable::testing::MockBackoffPolicy;
-using ::google::cloud::bigtable::testing::MockPollingPolicy;
-using ::google::cloud::bigtable::testing::MockRetryPolicy;
-using ::google::cloud::bigtable_internal::InstanceAdminTester;
-using ::google::cloud::testing_util::StatusIs;
-using ::testing::An;
-using ::testing::Contains;
-using ::testing::ElementsAreArray;
-using ::testing::NotNull;
-using ::testing::Return;
-using ::testing::UnorderedElementsAreArray;
-
-using MockConnection =
- ::google::cloud::bigtable_admin_mocks::MockBigtableInstanceAdminConnection;
-
-auto const kProjectId = "the-project";
-auto const kInstanceId = "the-instance";
-auto const kClusterId = "the-cluster";
-auto const kProfileId = "the-profile";
-auto const kProjectName = "projects/the-project";
-auto const kInstanceName = "projects/the-project/instances/the-instance";
-auto const kClusterName =
- "projects/the-project/instances/the-instance/clusters/the-cluster";
-auto const kProfileName =
- "projects/the-project/instances/the-instance/appProfiles/the-profile";
-
-std::string LocationName(std::string const& location) {
- return Location(Project(kProjectId), location).FullName();
-}
-
-Status FailingStatus() { return Status(StatusCode::kPermissionDenied, "fail"); }
-
-struct TestOption {
- using Type = int;
-};
-
-Options TestOptions() {
- return Options{}
- .set(grpc::InsecureChannelCredentials())
- .set(1);
-}
-
-void CheckOptions(Options const& options) {
- EXPECT_TRUE(
- options.has());
- EXPECT_TRUE(
- options.has());
- EXPECT_TRUE(
- options.has());
- EXPECT_TRUE(options.has());
- EXPECT_TRUE(options.has());
- EXPECT_TRUE(options.has());
-}
-
-/// A fixture for the bigtable::InstanceAdmin tests.
-class InstanceAdminTest : public ::testing::Test {
- protected:
- InstanceAdmin DefaultInstanceAdmin() {
- EXPECT_CALL(*connection_, options())
- .WillRepeatedly(Return(Options{}.set(1)));
- return InstanceAdmin(connection_, kProjectId);
- }
-
- std::shared_ptr connection_ =
- std::make_shared();
-};
-
-TEST_F(InstanceAdminTest, Project) {
- InstanceAdmin tested(MakeInstanceAdminClient(kProjectId, TestOptions()));
- EXPECT_EQ(kProjectId, tested.project_id());
- EXPECT_EQ(kProjectName, tested.project_name());
-}
-
-TEST_F(InstanceAdminTest, CopyConstructor) {
- auto source = InstanceAdmin(connection_, kProjectId);
- std::string const& expected = source.project_id();
- // NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
- InstanceAdmin copy(source);
- EXPECT_EQ(expected, copy.project_id());
-}
-
-TEST_F(InstanceAdminTest, MoveConstructor) {
- auto source = InstanceAdmin(connection_, kProjectId);
- std::string expected = source.project_id();
- InstanceAdmin copy(std::move(source));
- EXPECT_EQ(expected, copy.project_id());
-}
-
-TEST_F(InstanceAdminTest, CopyAssignment) {
- std::shared_ptr other_client =
- std::make_shared();
-
- auto source = InstanceAdmin(connection_, kProjectId);
- std::string const& expected = source.project_id();
- auto dest = InstanceAdmin(other_client, "other-project");
- EXPECT_NE(expected, dest.project_id());
- dest = source;
- EXPECT_EQ(expected, dest.project_id());
-}
-
-TEST_F(InstanceAdminTest, MoveAssignment) {
- std::shared_ptr other_client =
- std::make_shared();
-
- auto source = InstanceAdmin(connection_, kProjectId);
- std::string expected = source.project_id();
- auto dest = InstanceAdmin(other_client, "other-project");
- EXPECT_NE(expected, dest.project_id());
- dest = std::move(source);
- EXPECT_EQ(expected, dest.project_id());
-}
-
-TEST_F(InstanceAdminTest, WithNewTarget) {
- auto admin = InstanceAdmin(connection_, kProjectId);
- auto other_admin = admin.WithNewTarget("other-project");
- EXPECT_EQ(other_admin.project_id(), "other-project");
- EXPECT_EQ(other_admin.project_name(), Project("other-project").FullName());
-}
-
-TEST_F(InstanceAdminTest, LegacyConstructorSharesConnection) {
- auto admin_client = MakeInstanceAdminClient("test-project", TestOptions());
- auto admin_1 = InstanceAdmin(admin_client);
- auto admin_2 = InstanceAdmin(admin_client);
- auto conn_1 = InstanceAdminTester::Connection(admin_1);
- auto conn_2 = InstanceAdminTester::Connection(admin_2);
-
- EXPECT_EQ(conn_1, conn_2);
- EXPECT_THAT(conn_1, NotNull());
-}
-
-TEST_F(InstanceAdminTest, LegacyConstructorDefaultsPolicies) {
- auto admin_client = MakeInstanceAdminClient("test-project", TestOptions());
- auto admin = InstanceAdmin(std::move(admin_client));
- auto options = InstanceAdminTester::Options(admin);
- CheckOptions(options);
-}
-
-TEST_F(InstanceAdminTest, LegacyConstructorWithPolicies) {
- // In this test, we make a series of simple calls to verify that the policies
- // passed to the `InstanceAdmin` constructor are actually collected as
- // `Options`.
- //
- // Upon construction of an InstanceAdmin, each policy is cloned twice: Once
- // while processing the variadic parameters, once while converting from
- // Bigtable policies to common policies. This should explain the nested mocks
- // below.
-
- auto mock_r = std::make_shared();
- auto mock_b = std::make_shared();
- auto mock_p = std::make_shared();
-
- EXPECT_CALL(*mock_r, clone).WillOnce([] {
- auto clone_1 = std::make_unique();
- EXPECT_CALL(*clone_1, clone).WillOnce([] {
- auto clone_2 = std::make_unique();
- EXPECT_CALL(*clone_2, OnFailure(An()));
- return clone_2;
- });
- return clone_1;
- });
-
- EXPECT_CALL(*mock_b, clone).WillOnce([] {
- auto clone_1 = std::make_unique();
- EXPECT_CALL(*clone_1, clone).WillOnce([] {
- auto clone_2 = std::make_unique();
- EXPECT_CALL(*clone_2, OnCompletion(An()));
- return clone_2;
- });
- return clone_1;
- });
-
- EXPECT_CALL(*mock_p, clone).WillOnce([] {
- auto clone_1 = std::make_unique();
- EXPECT_CALL(*clone_1, clone).WillOnce([] {
- auto clone_2 = std::make_unique();
- EXPECT_CALL(*clone_2, WaitPeriod);
- return clone_2;
- });
- return clone_1;
- });
-
- auto admin_client = MakeInstanceAdminClient("test-project", TestOptions());
- auto admin =
- InstanceAdmin(std::move(admin_client), *mock_r, *mock_b, *mock_p);
- auto options = InstanceAdminTester::Options(admin);
- CheckOptions(options);
-
- auto const& common_retry =
- options.get();
- (void)common_retry->OnFailure({});
-
- auto const& common_backoff =
- options.get();
- (void)common_backoff->OnCompletion();
-
- auto const& common_polling =
- options.get();
- (void)common_polling->WaitPeriod();
-}
-
-TEST_F(InstanceAdminTest, ListInstancesSuccess) {
- auto tested = DefaultInstanceAdmin();
- std::vector const expected_names = {
- InstanceName(kProjectId, "i0"), InstanceName(kProjectId, "i1")};
- std::vector const expected_fails = {"l0", "l1"};
-
- EXPECT_CALL(*connection_, ListInstances)
- .WillOnce([&expected_names, &expected_fails](
- btadmin::ListInstancesRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kProjectName, request.parent());
-
- btadmin::ListInstancesResponse response;
- for (auto const& name : expected_names) {
- auto& instance = *response.add_instances();
- instance.set_name(name);
- }
- for (auto const& loc : expected_fails) {
- *response.add_failed_locations() = loc;
- }
- return make_status_or(response);
- });
-
- auto actual = tested.ListInstances();
- ASSERT_STATUS_OK(actual);
- std::vector actual_names;
- std::transform(actual->instances.begin(), actual->instances.end(),
- std::back_inserter(actual_names),
- [](btadmin::Instance const& i) { return i.name(); });
-
- EXPECT_THAT(actual_names, ElementsAreArray(expected_names));
- EXPECT_THAT(actual->failed_locations, ElementsAreArray(expected_fails));
-}
-
-TEST_F(InstanceAdminTest, ListInstancesFailure) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, ListInstances).WillOnce(Return(FailingStatus()));
-
- EXPECT_THAT(tested.ListInstances(), StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, CreateInstance) {
- auto tested = DefaultInstanceAdmin();
- auto constexpr kDisplayName = "display name";
- std::vector const expected_location_names = {LocationName("l0"),
- LocationName("l1")};
- std::map cluster_map = {
- {"c0", ClusterConfig("l0", 3, btadmin::HDD)},
- {"c1", ClusterConfig("l1", 3, btadmin::HDD)}};
- auto config = InstanceConfig(kInstanceId, kDisplayName, cluster_map);
-
- EXPECT_CALL(*connection_,
- CreateInstance(An()))
- .WillOnce([&](btadmin::CreateInstanceRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceId, request.instance_id());
- EXPECT_EQ(kProjectName, request.parent());
- EXPECT_EQ(kDisplayName, request.instance().display_name());
- std::vector actual_location_names;
- for (auto&& c : request.clusters()) {
- actual_location_names.emplace_back(c.second.location());
- }
- EXPECT_THAT(actual_location_names,
- UnorderedElementsAreArray(expected_location_names));
- return make_ready_future>(FailingStatus());
- });
-
- EXPECT_THAT(tested.CreateInstance(config).get(),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, CreateCluster) {
- auto tested = DefaultInstanceAdmin();
- auto const location_name = LocationName("the-location");
- auto config = ClusterConfig("the-location", 3, btadmin::HDD);
-
- EXPECT_CALL(*connection_,
- CreateCluster(An()))
- .WillOnce([&](btadmin::CreateClusterRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kClusterId, request.cluster_id());
- EXPECT_EQ(kInstanceName, request.parent());
- EXPECT_EQ(location_name, request.cluster().location());
- EXPECT_EQ(3, request.cluster().serve_nodes());
- EXPECT_EQ(btadmin::HDD, request.cluster().default_storage_type());
- return make_ready_future>(FailingStatus());
- });
-
- EXPECT_THAT(tested.CreateCluster(config, kInstanceId, kClusterId).get(),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, UpdateInstance) {
- auto tested = DefaultInstanceAdmin();
- auto constexpr kDisplayName = "updated display name";
- InstanceUpdateConfig config({});
- config.set_display_name(kDisplayName);
-
- EXPECT_CALL(
- *connection_,
- PartialUpdateInstance(An()))
- .WillOnce([&](btadmin::PartialUpdateInstanceRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kDisplayName, request.instance().display_name());
- EXPECT_THAT(request.update_mask().paths(), Contains("display_name"));
- return make_ready_future>(FailingStatus());
- });
-
- EXPECT_THAT(tested.UpdateInstance(config).get(),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, GetInstance) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, GetInstance)
- .WillOnce([&](btadmin::GetInstanceRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.name());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.GetInstance(kInstanceId),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, DeleteInstance) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, DeleteInstance)
- .WillOnce([&](btadmin::DeleteInstanceRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.name());
- return Status();
- });
-
- EXPECT_STATUS_OK(tested.DeleteInstance(kInstanceId));
-}
-
-TEST_F(InstanceAdminTest, GetCluster) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, GetCluster)
- .WillOnce([&](btadmin::GetClusterRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kClusterName, request.name());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.GetCluster(kInstanceId, kClusterId),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, ListClustersSuccess) {
- auto tested = DefaultInstanceAdmin();
- std::vector const expected_names = {
- ClusterName(kProjectId, kInstanceId, "c0"),
- ClusterName(kProjectId, kInstanceId, "c1")};
- std::vector const expected_fails = {"l0", "l1"};
-
- EXPECT_CALL(*connection_, ListClusters)
- .WillOnce([&](btadmin::ListClustersRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.parent());
-
- btadmin::ListClustersResponse response;
- for (auto const& name : expected_names) {
- auto& cluster = *response.add_clusters();
- cluster.set_name(name);
- }
- for (auto const& loc : expected_fails) {
- *response.add_failed_locations() = loc;
- }
- return make_status_or(response);
- });
-
- auto actual = tested.ListClusters(kInstanceId);
- ASSERT_STATUS_OK(actual);
- std::vector actual_names;
- std::transform(actual->clusters.begin(), actual->clusters.end(),
- std::back_inserter(actual_names),
- [](btadmin::Cluster const& c) { return c.name(); });
-
- EXPECT_THAT(actual_names, ElementsAreArray(expected_names));
- EXPECT_THAT(actual->failed_locations, ElementsAreArray(expected_fails));
-}
-
-TEST_F(InstanceAdminTest, ListClustersFailure) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, ListClusters)
- .WillOnce([&](btadmin::ListClustersRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- // Verify that calling `ListClusters` with no arguments sets the
- // instance-id to "-"
- auto const instance_name = InstanceName(kProjectId, "-");
- EXPECT_EQ(instance_name, request.parent());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.ListClusters(), StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, UpdateCluster) {
- auto tested = DefaultInstanceAdmin();
- auto const location_name = LocationName("the-location");
- btadmin::Cluster c;
- c.set_name(kClusterName);
- c.set_location(location_name);
- c.set_serve_nodes(3);
- c.set_default_storage_type(btadmin::HDD);
- auto config = ClusterConfig(std::move(c));
-
- EXPECT_CALL(*connection_, UpdateCluster(An()))
- .WillOnce([&](btadmin::Cluster const& cluster) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kClusterName, cluster.name());
- EXPECT_EQ(location_name, cluster.location());
- EXPECT_EQ(3, cluster.serve_nodes());
- EXPECT_EQ(btadmin::HDD, cluster.default_storage_type());
- return make_ready_future>(FailingStatus());
- });
-
- EXPECT_THAT(tested.UpdateCluster(config).get(),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, DeleteCluster) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, DeleteCluster)
- .WillOnce([&](btadmin::DeleteClusterRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kClusterName, request.name());
- return Status();
- });
-
- EXPECT_STATUS_OK(tested.DeleteCluster(kInstanceId, kClusterId));
-}
-
-TEST_F(InstanceAdminTest, CreateAppProfile) {
- auto tested = DefaultInstanceAdmin();
- auto config = AppProfileConfig::MultiClusterUseAny(kProfileId);
-
- EXPECT_CALL(*connection_, CreateAppProfile)
- .WillOnce([&](btadmin::CreateAppProfileRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kProfileId, request.app_profile_id());
- EXPECT_EQ(kInstanceName, request.parent());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.CreateAppProfile(kInstanceId, config),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, GetAppProfile) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, GetAppProfile)
- .WillOnce([&](btadmin::GetAppProfileRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kProfileName, request.name());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.GetAppProfile(kInstanceId, kProfileId),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, UpdateAppProfile) {
- auto tested = DefaultInstanceAdmin();
- auto constexpr kDescription = "description";
- auto config = AppProfileUpdateConfig().set_description(kDescription);
-
- EXPECT_CALL(*connection_,
- UpdateAppProfile(An()))
- .WillOnce([&](btadmin::UpdateAppProfileRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kProfileName, request.app_profile().name());
- EXPECT_EQ(kDescription, request.app_profile().description());
- return make_ready_future>(
- FailingStatus());
- });
-
- EXPECT_THAT(tested.UpdateAppProfile(kInstanceId, kProfileId, config).get(),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, ListAppProfilesSuccess) {
- auto tested = DefaultInstanceAdmin();
- std::vector const expected_names = {
- AppProfileName(kProjectId, kInstanceId, "p0"),
- AppProfileName(kProjectId, kInstanceId, "p1")};
-
- auto iter = expected_names.begin();
- EXPECT_CALL(*connection_, ListAppProfiles)
- .WillOnce([&iter, &expected_names](
- btadmin::ListAppProfilesRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.parent());
-
- using ::google::cloud::internal::MakeStreamRange;
- using ::google::cloud::internal::StreamReader;
- auto reader = [&iter, &expected_names]()
- -> StreamReader::result_type {
- if (iter != expected_names.end()) {
- btadmin::AppProfile p;
- p.set_name(*iter);
- ++iter;
- return p;
- }
- return Status();
- };
- return MakeStreamRange(std::move(reader));
- });
-
- auto profiles = tested.ListAppProfiles(kInstanceId);
- ASSERT_STATUS_OK(profiles);
- std::vector names;
- std::transform(profiles->begin(), profiles->end(), std::back_inserter(names),
- [](btadmin::AppProfile const& p) { return p.name(); });
-
- EXPECT_THAT(names, ElementsAreArray(expected_names));
-}
-
-TEST_F(InstanceAdminTest, ListAppProfilesFailure) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, ListAppProfiles)
- .WillOnce([&](btadmin::ListAppProfilesRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.parent());
-
- using ::google::cloud::internal::MakeStreamRange;
- return MakeStreamRange(
- [] { return FailingStatus(); });
- });
-
- EXPECT_THAT(tested.ListAppProfiles(kInstanceId),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, DeleteAppProfile) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, DeleteAppProfile)
- .WillOnce([&](btadmin::DeleteAppProfileRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kProfileName, request.name());
- EXPECT_EQ(true, request.ignore_warnings());
- return Status();
- });
-
- EXPECT_STATUS_OK(tested.DeleteAppProfile(kInstanceId, kProfileId, true));
-}
-
-TEST_F(InstanceAdminTest, GetNativeIamPolicy) {
- auto tested = DefaultInstanceAdmin();
-
- EXPECT_CALL(*connection_, GetIamPolicy)
- .WillOnce([&](iamproto::GetIamPolicyRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.resource());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.GetNativeIamPolicy(kInstanceId),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, SetNativeIamPolicy) {
- auto tested = DefaultInstanceAdmin();
- iamproto::Policy policy;
- policy.set_etag("tag");
- policy.set_version(3);
-
- EXPECT_CALL(*connection_, SetIamPolicy)
- .WillOnce([&](iamproto::SetIamPolicyRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.resource());
- EXPECT_EQ("tag", request.policy().etag());
- EXPECT_EQ(3, request.policy().version());
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.SetIamPolicy(kInstanceId, policy),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-TEST_F(InstanceAdminTest, TestIamPermissionsSuccess) {
- auto tested = DefaultInstanceAdmin();
- std::vector const expected_permissions = {"writer", "reader"};
- std::vector const returned_permissions = {"reader"};
-
- EXPECT_CALL(*connection_, TestIamPermissions)
- .WillOnce([&](iamproto::TestIamPermissionsRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.resource());
- std::vector actual_permissions;
- for (auto const& c : request.permissions()) {
- actual_permissions.emplace_back(c);
- }
- EXPECT_THAT(actual_permissions,
- UnorderedElementsAreArray(expected_permissions));
-
- iamproto::TestIamPermissionsResponse r;
- for (auto const& p : returned_permissions) r.add_permissions(p);
- return r;
- });
-
- auto resp = tested.TestIamPermissions(kInstanceId, expected_permissions);
- ASSERT_STATUS_OK(resp);
- EXPECT_THAT(*resp, ElementsAreArray(returned_permissions));
-}
-
-TEST_F(InstanceAdminTest, TestIamPermissionsFailure) {
- auto tested = DefaultInstanceAdmin();
- std::vector const expected_permissions = {"writer", "reader"};
-
- EXPECT_CALL(*connection_, TestIamPermissions)
- .WillOnce([&](iamproto::TestIamPermissionsRequest const& request) {
- CheckOptions(google::cloud::internal::CurrentOptions());
- EXPECT_EQ(kInstanceName, request.resource());
- std::vector actual_permissions;
- for (auto const& c : request.permissions()) {
- actual_permissions.emplace_back(c);
- }
- EXPECT_THAT(actual_permissions,
- UnorderedElementsAreArray(expected_permissions));
- return FailingStatus();
- });
-
- EXPECT_THAT(tested.TestIamPermissions(kInstanceId, expected_permissions),
- StatusIs(StatusCode::kPermissionDenied));
-}
-
-} // namespace
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/table_admin.cc b/google/cloud/bigtable/table_admin.cc
deleted file mode 100644
index fb7758553c062..0000000000000
--- a/google/cloud/bigtable/table_admin.cc
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright 2017 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "google/cloud/bigtable/table_admin.h"
-#include "google/cloud/bigtable/admin/bigtable_table_admin_client.h"
-#include "google/cloud/bigtable/wait_for_consistency.h"
-#include "google/cloud/internal/time_utils.h"
-#include "google/protobuf/duration.pb.h"
-#include
-
-namespace btadmin = ::google::bigtable::admin::v2;
-
-namespace google {
-namespace cloud {
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-static_assert(std::is_copy_constructible::value,
- "bigtable::TableAdmin must be constructible");
-static_assert(std::is_copy_assignable::value,
- "bigtable::TableAdmin must be assignable");
-
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::ENCRYPTION_VIEW;
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::FULL;
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::NAME_ONLY;
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::REPLICATION_VIEW;
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::SCHEMA_VIEW;
-// NOLINTNEXTLINE(readability-identifier-naming)
-constexpr TableAdmin::TableView TableAdmin::VIEW_UNSPECIFIED;
-
-StatusOr TableAdmin::CreateTable(std::string table_id,
- TableConfig config) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = std::move(config).as_proto();
- request.set_parent(instance_name());
- request.set_table_id(std::move(table_id));
- return connection_->CreateTable(request);
-}
-
-StatusOr> TableAdmin::ListTables(
- btadmin::Table::View view) {
- google::cloud::internal::OptionsSpan span(options_);
- std::vector result;
-
- btadmin::ListTablesRequest request;
- request.set_parent(instance_name());
- request.set_view(view);
- auto sr = connection_->ListTables(request);
- for (auto& t : sr) {
- if (!t) return std::move(t).status();
- result.emplace_back(*std::move(t));
- }
- return result;
-}
-
-StatusOr TableAdmin::GetTable(std::string const& table_id,
- btadmin::Table::View view) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GetTableRequest request;
- request.set_name(TableName(table_id));
- request.set_view(view);
- return connection_->GetTable(request);
-}
-
-Status TableAdmin::DeleteTable(std::string const& table_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteTableRequest request;
- request.set_name(TableName(table_id));
- return connection_->DeleteTable(request);
-}
-
-btadmin::CreateBackupRequest TableAdmin::CreateBackupParams::AsProto(
- std::string instance_name) const {
- btadmin::CreateBackupRequest proto;
- proto.set_parent(instance_name + "/clusters/" + cluster_id);
- proto.set_backup_id(backup_id);
- proto.mutable_backup()->set_source_table(std::move(instance_name) +
- "/tables/" + table_name);
- *proto.mutable_backup()->mutable_expire_time() =
- google::cloud::internal::ToProtoTimestamp(expire_time);
- return proto;
-}
-
-StatusOr TableAdmin::CreateBackup(
- CreateBackupParams const& params) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = params.AsProto(instance_name());
- return connection_->CreateBackup(request).get();
-}
-
-StatusOr TableAdmin::GetBackup(std::string const& cluster_id,
- std::string const& backup_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GetBackupRequest request;
- request.set_name(BackupName(cluster_id, backup_id));
- return connection_->GetBackup(request);
-}
-
-btadmin::UpdateBackupRequest TableAdmin::UpdateBackupParams::AsProto(
- std::string const& instance_name) const {
- btadmin::UpdateBackupRequest proto;
- proto.mutable_backup()->set_name(instance_name + "/clusters/" + cluster_id +
- "/backups/" + backup_name);
- *proto.mutable_backup()->mutable_expire_time() =
- google::cloud::internal::ToProtoTimestamp(expire_time);
- proto.mutable_update_mask()->add_paths("expire_time");
- return proto;
-}
-
-StatusOr TableAdmin::UpdateBackup(
- UpdateBackupParams const& params) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::UpdateBackupRequest request = params.AsProto(instance_name());
- return connection_->UpdateBackup(request);
-}
-
-Status TableAdmin::DeleteBackup(btadmin::Backup const& backup) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteBackupRequest request;
- request.set_name(backup.name());
- return connection_->DeleteBackup(request);
-}
-
-Status TableAdmin::DeleteBackup(std::string const& cluster_id,
- std::string const& backup_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DeleteBackupRequest request;
- request.set_name(BackupName(cluster_id, backup_id));
- return connection_->DeleteBackup(request);
-}
-
-btadmin::ListBackupsRequest TableAdmin::ListBackupsParams::AsProto(
- std::string const& instance_name) const {
- btadmin::ListBackupsRequest proto;
- proto.set_parent(cluster_id ? instance_name + "/clusters/" + *cluster_id
- : instance_name + "/clusters/-");
- if (filter) *proto.mutable_filter() = *filter;
- if (order_by) *proto.mutable_order_by() = *order_by;
- return proto;
-}
-
-StatusOr> TableAdmin::ListBackups(
- ListBackupsParams const& params) {
- google::cloud::internal::OptionsSpan span(options_);
- std::vector result;
-
- btadmin::ListBackupsRequest request = params.AsProto(instance_name());
- auto sr = connection_->ListBackups(request);
- for (auto& b : sr) {
- if (!b) return std::move(b).status();
- result.emplace_back(*std::move(b));
- }
- return result;
-}
-
-btadmin::RestoreTableRequest TableAdmin::RestoreTableParams::AsProto(
- std::string const& instance_name) const {
- btadmin::RestoreTableRequest proto;
- proto.set_parent(instance_name);
- proto.set_table_id(table_id);
- proto.set_backup(instance_name + "/clusters/" + cluster_id + "/backups/" +
- backup_id);
- return proto;
-}
-
-StatusOr TableAdmin::RestoreTable(
- RestoreTableParams const& params) {
- auto p = RestoreTableFromInstanceParams{
- params.table_id, BackupName(params.cluster_id, params.backup_id)};
- return RestoreTable(std::move(p));
-}
-
-btadmin::RestoreTableRequest AsProto(
- std::string const& instance_name,
- TableAdmin::RestoreTableFromInstanceParams p) {
- btadmin::RestoreTableRequest proto;
- proto.set_parent(instance_name);
- proto.set_table_id(std::move(p.table_id));
- proto.set_backup(std::move(p.backup_name));
- return proto;
-}
-
-StatusOr TableAdmin::RestoreTable(
- RestoreTableFromInstanceParams params) {
- google::cloud::internal::OptionsSpan span(options_);
- auto request = AsProto(instance_name(), std::move(params));
- return connection_->RestoreTable(request).get();
-}
-
-StatusOr TableAdmin::ModifyColumnFamilies(
- std::string const& table_id,
- std::vector modifications) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::ModifyColumnFamiliesRequest request;
- request.set_name(TableName(table_id));
- for (auto& m : modifications) {
- google::cloud::internal::OptionsSpan span(options_);
- *request.add_modifications() = std::move(m).as_proto();
- }
- return connection_->ModifyColumnFamilies(request);
-}
-
-Status TableAdmin::DropRowsByPrefix(std::string const& table_id,
- std::string row_key_prefix) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DropRowRangeRequest request;
- request.set_name(TableName(table_id));
- request.set_row_key_prefix(std::move(row_key_prefix));
- return connection_->DropRowRange(request);
-}
-
-future> TableAdmin::WaitForConsistency(
- std::string const& table_id, std::string const& consistency_token) {
- // We avoid lifetime issues due to ownership cycles, by holding the
- // `BackgroundThreads` which run the `CompletionQueue` outside of the
- // operation, in this class. If the `BackgroundThreads` running the
- // `CompletionQueue` were instead owned by the Connection, we would have an
- // ownership cycle. We have made this mistake before. See #7740 for more
- // details.
- auto client = bigtable_admin::BigtableTableAdminClient(connection_);
- return bigtable_admin::AsyncWaitForConsistency(cq_, std::move(client),
- TableName(table_id),
- consistency_token, options_)
- .then([](future f) -> StatusOr {
- auto s = f.get();
- if (!s.ok()) return s;
- return Consistency::kConsistent;
- });
-}
-
-Status TableAdmin::DropAllRows(std::string const& table_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::DropRowRangeRequest request;
- request.set_name(TableName(table_id));
- request.set_delete_all_data_from_table(true);
- return connection_->DropRowRange(request);
-}
-
-StatusOr TableAdmin::GenerateConsistencyToken(
- std::string const& table_id) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::GenerateConsistencyTokenRequest request;
- request.set_name(TableName(table_id));
- auto sor = connection_->GenerateConsistencyToken(request);
- if (!sor) return std::move(sor).status();
- return std::move(*sor->mutable_consistency_token());
-}
-
-StatusOr TableAdmin::CheckConsistency(
- std::string const& table_id, std::string const& consistency_token) {
- google::cloud::internal::OptionsSpan span(options_);
- btadmin::CheckConsistencyRequest request;
- request.set_name(TableName(table_id));
- request.set_consistency_token(consistency_token);
- auto sor = connection_->CheckConsistency(request);
- if (!sor) return std::move(sor).status();
- return sor->consistent() ? Consistency::kConsistent
- : Consistency::kInconsistent;
-}
-
-StatusOr TableAdmin::GetIamPolicy(
- std::string const& table_id) {
- return GetIamPolicyImpl(TableName(table_id));
-}
-
-StatusOr TableAdmin::GetIamPolicy(
- std::string const& cluster_id, std::string const& backup_id) {
- return GetIamPolicyImpl(BackupName(cluster_id, backup_id));
-}
-
-StatusOr TableAdmin::GetIamPolicyImpl(
- std::string resource) {
- google::cloud::internal::OptionsSpan span(options_);
- ::google::iam::v1::GetIamPolicyRequest request;
- request.set_resource(std::move(resource));
- return connection_->GetIamPolicy(request);
-}
-
-StatusOr TableAdmin::SetIamPolicy(
- std::string const& table_id, google::iam::v1::Policy const& iam_policy) {
- return SetIamPolicyImpl(TableName(table_id), iam_policy);
-}
-
-StatusOr TableAdmin::SetIamPolicy(
- std::string const& cluster_id, std::string const& backup_id,
- google::iam::v1::Policy const& iam_policy) {
- return SetIamPolicyImpl(BackupName(cluster_id, backup_id), iam_policy);
-}
-
-StatusOr TableAdmin::SetIamPolicyImpl(
- std::string resource, google::iam::v1::Policy const& iam_policy) {
- google::cloud::internal::OptionsSpan span(options_);
- ::google::iam::v1::SetIamPolicyRequest request;
- request.set_resource(std::move(resource));
- *request.mutable_policy() = iam_policy;
- return connection_->SetIamPolicy(request);
-}
-
-StatusOr> TableAdmin::TestIamPermissions(
- std::string const& table_id, std::vector const& permissions) {
- return TestIamPermissionsImpl(TableName(table_id), permissions);
-}
-
-StatusOr> TableAdmin::TestIamPermissions(
- std::string const& cluster_id, std::string const& backup_id,
- std::vector const& permissions) {
- return TestIamPermissionsImpl(BackupName(cluster_id, backup_id), permissions);
-}
-
-StatusOr> TableAdmin::TestIamPermissionsImpl(
- std::string resource, std::vector const& permissions) {
- google::cloud::internal::OptionsSpan span(options_);
- ::google::iam::v1::TestIamPermissionsRequest request;
- request.set_resource(std::move(resource));
- for (auto const& permission : permissions) {
- request.add_permissions(permission);
- }
- auto sor = connection_->TestIamPermissions(request);
- if (!sor) return std::move(sor).status();
- auto response = *std::move(sor);
- std::vector result;
- auto& ps = *response.mutable_permissions();
- std::move(ps.begin(), ps.end(), std::back_inserter(result));
- return result;
-}
-
-std::string TableAdmin::InstanceName() const {
- return google::cloud::bigtable::InstanceName(project_id_, instance_id_);
-}
-
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable
-} // namespace cloud
-} // namespace google
diff --git a/google/cloud/bigtable/table_admin.h b/google/cloud/bigtable/table_admin.h
deleted file mode 100644
index a53831d073b13..0000000000000
--- a/google/cloud/bigtable/table_admin.h
+++ /dev/null
@@ -1,1136 +0,0 @@
-// Copyright 2017 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
-#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_ADMIN_H
-
-#include "google/cloud/bigtable/admin/bigtable_table_admin_connection.h"
-#include "google/cloud/bigtable/admin_client.h"
-#include "google/cloud/bigtable/column_family.h"
-#include "google/cloud/bigtable/completion_queue.h"
-#include "google/cloud/bigtable/iam_policy.h"
-#include "google/cloud/bigtable/internal/convert_policies.h"
-#include "google/cloud/bigtable/polling_policy.h"
-#include "google/cloud/bigtable/resource_names.h"
-#include "google/cloud/bigtable/table_config.h"
-#include "google/cloud/bigtable/version.h"
-#include "google/cloud/future.h"
-#include "google/cloud/grpc_error_delegate.h"
-#include "google/cloud/options.h"
-#include "google/cloud/status_or.h"
-#include "absl/types/optional.h"
-#include
-#include
-#include
-#include
-#include
-
-namespace google {
-namespace cloud {
-namespace bigtable_internal {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-class TableAdminTester;
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
-} // namespace bigtable_internal
-namespace bigtable {
-GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
-/// The result of checking replication against a given token.
-enum class Consistency {
- /// Some of the mutations created before the consistency token have not been
- /// received by all the table replicas.
- kInconsistent,
- /// All mutations created before the consistency token have been received by
- /// all the table replicas.
- kConsistent,
-};
-
-/**
- * Implements the API to administer tables in a Cloud Bigtable instance.
- *
- * @par Thread-safety
- * 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 concurrently on the same
- * instance of this class is not guaranteed to work.
- *
- * @par Cost
- * Creating a new object of type `TableAdmin` is comparable to creating a few
- * objects of type `std::string` or a few objects of type
- * `std::shared_ptr`. The class represents a shallow handle to a remote
- * object.
- *
- * @par Error Handling
- * This class uses `StatusOr` to report errors. When an operation fails to
- * perform its work the returned `StatusOr` contains the error details. If
- * the `ok()` member function in the `StatusOr` returns `true` then it
- * contains the expected result. Operations that do not return a value simply
- * return a `google::cloud::Status` indicating success or the details of the
- * error Please consult the [`StatusOr`
- * documentation](#google::cloud::StatusOr) for more details.
- *
- * @code
- * namespace cbt = google::cloud::bigtable;
- * namespace btadmin = google::bigtable::admin::v2;
- * cbt::TableAdmin admin = ...;
- * google::cloud::StatusOr metadata = admin.GetTable(...);
- *
- * if (!metadata) {
- * std::cerr << "Error fetching table metadata\n";
- * return;
- * }
- *
- * // Use "metadata" as a smart pointer here, e.g.:
- * std::cout << "The full table name is " << table->name() << " the table has "
- * << table->column_families_size() << " column families\n";
- * @endcode
- *
- * In addition, the @ref index "main page" contains examples using `StatusOr`
- * to handle errors.
- *
- * @par Retry, Backoff, and Idempotency Policies
- * The library automatically retries requests that fail with transient errors,
- * and uses [truncated exponential backoff][backoff-link] to backoff between
- * retries. The default policies are to continue retrying for up to 10 minutes.
- * On each transient failure the backoff period is doubled, starting with an
- * initial backoff of 100 milliseconds. The backoff period growth is truncated
- * at 60 seconds. The default idempotency policy is to only retry idempotent
- * operations. Note that most operations that change state are **not**
- * idempotent.
- *
- * The application can override these policies when constructing objects of this
- * class. The documentation for the constructors show examples of this in
- * action.
- *
- * [backoff-link]: https://cloud.google.com/storage/docs/exponential-backoff
- *
- * @par Equality
- * `TableAdmin` objects will compare equal iff they were created with the
- * same `DataClient` and target the same Instance resource. Note that
- * `TableAdmin` objects can compare equal with different retry/backoff/polling
- * policies.
- *
- * @see https://cloud.google.com/bigtable/ for an overview of Cloud Bigtable.
- *
- * @see https://cloud.google.com/bigtable/docs/overview for an overview of the
- * Cloud Bigtable data model.
- *
- * @see https://cloud.google.com/bigtable/docs/instances-clusters-nodes for an
- * introduction of the main APIs into Cloud Bigtable.
- *
- * @see https://cloud.google.com/bigtable/docs/reference/service-apis-overview
- * for an overview of the underlying Cloud Bigtable API.
- *
- * @see #google::cloud::StatusOr for a description of the error reporting class
- * used by this library.
- *
- * @see `LimitedTimeRetryPolicy` and `LimitedErrorCountRetryPolicy` for
- * alternative retry policies.
- *
- * @see `ExponentialBackoffPolicy` to configure different parameters for the
- * exponential backoff policy.
- *
- * @see `SafeIdempotentMutationPolicy` and `AlwaysRetryMutationPolicy` for
- * alternative idempotency policies.
- */
-class TableAdmin {
- public:
- /**
- * @param client the interface to create grpc stubs, report errors, etc.
- * @param instance_id the id of the instance, e.g., "my-instance", the full
- * name (e.g. '/projects/my-project/instances/my-instance') is built using
- * the project id in the @p client parameter.
- */
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- TableAdmin(std::shared_ptr client, std::string instance_id)
- : connection_(client->connection_),
- cq_(client->cq_),
- background_threads_(client->background_threads_),
- project_id_(client->project()),
- instance_id_(std::move(instance_id)),
- instance_name_(InstanceName()),
- retry_prototype_(
- DefaultRPCRetryPolicy(internal::kBigtableTableAdminLimits)),
- backoff_prototype_(
- DefaultRPCBackoffPolicy(internal::kBigtableTableAdminLimits)),
- polling_prototype_(
- DefaultPollingPolicy(internal::kBigtableTableAdminLimits)),
- options_(google::cloud::internal::MergeOptions(
- bigtable_internal::MakeTableAdminOptions(
- retry_prototype_, backoff_prototype_, polling_prototype_),
- connection_->options())) {}
-
- /**
- * Create a new TableAdmin using explicit policies to handle RPC errors.
- *
- * @param client the interface to create grpc stubs, report errors, etc.
- * @param instance_id the id of the instance, e.g., "my-instance", the full
- * name (e.g. '/projects/my-project/instances/my-instance') is built using
- * the project id in the @p client parameter.
- * @param policies the set of policy overrides for this object.
- * @tparam Policies the types of the policies to override, the types must
- * derive from one of the following types:
- * - `RPCBackoffPolicy` how to backoff from a failed RPC. Currently only
- * `ExponentialBackoffPolicy` is implemented. You can also create your
- * own policies that backoff using a different algorithm.
- * - `RPCRetryPolicy` for how long to retry failed RPCs. Use
- * `LimitedErrorCountRetryPolicy` to limit the number of failures
- * allowed. Use `LimitedTimeRetryPolicy` to bound the time for any
- * request. You can also create your own policies that combine time and
- * error counts.
- * - `PollingPolicy` for how long will the class wait for
- * `google.longrunning.Operation` to complete. This class combines both
- * the backoff policy for checking long running operations and the
- * retry policy.
- *
- * @see GenericPollingPolicy, ExponentialBackoffPolicy,
- * LimitedErrorCountRetryPolicy, LimitedTimeRetryPolicy.
- */
- template
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- TableAdmin(std::shared_ptr client, std::string instance_id,
- Policies&&... policies)
- : connection_(client->connection_),
- cq_(client->cq_),
- background_threads_(client->background_threads_),
- project_id_(client->project()),
- instance_id_(std::move(instance_id)),
- instance_name_(InstanceName()),
- retry_prototype_(
- DefaultRPCRetryPolicy(internal::kBigtableTableAdminLimits)),
- backoff_prototype_(
- DefaultRPCBackoffPolicy(internal::kBigtableTableAdminLimits)),
- polling_prototype_(
- DefaultPollingPolicy(internal::kBigtableTableAdminLimits)) {
- ChangePolicies(std::forward(policies)...);
- options_ = google::cloud::internal::MergeOptions(
- bigtable_internal::MakeTableAdminOptions(
- retry_prototype_, backoff_prototype_, polling_prototype_),
- connection_->options());
- }
-
- TableAdmin(TableAdmin const&) = default;
- TableAdmin& operator=(TableAdmin const&) = default;
-
- friend bool operator==(TableAdmin const& a, TableAdmin const& b) noexcept {
- return a.connection_ == b.connection_ &&
- a.instance_name_ == b.instance_name_;
- }
- friend bool operator!=(TableAdmin const& a, TableAdmin const& b) noexcept {
- return !(a == b);
- }
-
- ///@{
- /// @name Convenience shorthands for the schema views.
- using TableView = ::google::bigtable::admin::v2::Table::View;
- /// Only populate 'name' and fields related to the table's encryption state.
- static auto constexpr ENCRYPTION_VIEW = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::ENCRYPTION_VIEW;
- /// Populate all the fields in the response.
- static auto constexpr FULL = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::FULL;
- /// Populate only the name in the responses.
- static auto constexpr NAME_ONLY = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::NAME_ONLY;
- /// Populate only the name and the fields related to the table replication
- /// state.
- static auto constexpr REPLICATION_VIEW = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::REPLICATION_VIEW;
- /// Populate only the name and the fields related to the table schema.
- static auto constexpr SCHEMA_VIEW = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::SCHEMA_VIEW;
- /// Use the default view as defined for each function.
- static auto constexpr VIEW_UNSPECIFIED = // NOLINT(readability-identifier-naming)
- google::bigtable::admin::v2::Table::VIEW_UNSPECIFIED;
- ///@}
-
- std::string const& project() const { return project_id_; }
- std::string const& instance_id() const { return instance_id_; }
- std::string const& instance_name() const { return instance_name_; }
-
- /**
- * Returns a TableAdmin that reuses the connection and configuration of this
- * TableAdmin, but with a different resource name.
- */
- TableAdmin WithNewTarget(std::string project_id,
- std::string instance_id) const {
- auto table = *this;
- table.project_id_ = std::move(project_id);
- table.instance_id_ = std::move(instance_id);
- table.instance_name_ = table.InstanceName();
- return table;
- }
-
- /**
- * Create a new table in the instance.
- *
- * @param table_id the name of the table relative to the instance managed by
- * this object. The full table name is
- * `projects//instances//tables/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of this object.
- * @param config the initial schema for the table.
- * @return the attributes of the newly created table. Notice that the server
- * only populates the table_name() field at this time.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc create table
- */
- StatusOr<::google::bigtable::admin::v2::Table> CreateTable(
- std::string table_id, TableConfig config);
-
- /**
- * Return all the tables in the instance.
- *
- * @param view define what information about the tables is retrieved.
- * - `VIEW_UNSPECIFIED`: equivalent to `VIEW_SCHEMA`.
- * - `NAME`: return only the name of the table.
- * - `VIEW_SCHEMA`: return the name and the schema.
- * - `FULL`: return all the information about the table.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc list tables
- */
- StatusOr> ListTables(
- ::google::bigtable::admin::v2::Table::View view);
-
- /**
- * Get information about a single table.
- *
- * @param table_id the id of the table within the instance associated with
- * this object. The full name of the table is
- * `this->instance_name() + "/tables/" + table_id`
- * @param view describes how much information to get about the name.
- * - VIEW_UNSPECIFIED: equivalent to VIEW_SCHEMA.
- * - NAME: return only the name of the table.
- * - VIEW_SCHEMA: return the name and the schema.
- * - FULL: return all the information about the table.
- * @return the information about the table or status.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc get table
- */
- StatusOr<::google::bigtable::admin::v2::Table> GetTable(
- std::string const& table_id, TableView view = SCHEMA_VIEW);
-
- /**
- * Delete a table.
- *
- * @param table_id the id of the table within the instance associated with
- * this object. The full name of the table is
- * `this->instance_name() + "/tables/" + table_id`
- *
- * @return status of the operation.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc delete table
- */
- Status DeleteTable(std::string const& table_id);
-
- /**
- * Parameters for `CreateBackup`.
- *
- * @param cluster_id the name of the cluster relative to the instance managed
- * by the `TableAdmin` object. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param backup_id the name of the backup relative to the cluster specified.
- * The full backup name is
- * `projects//instances//clusters//backups/`
- * where PROJECT_ID is obtained from the associated AdminClient,
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
- * CLUSTER_ID is the cluster_id specified for this object.
- * @param table_id the id of the table within the instance to be backed up.
- * The full name of the table is
- * `projects//instances//tables/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param expire_time the date and time when the created backup will expire.
- */
- struct CreateBackupParams {
- CreateBackupParams() = default;
- CreateBackupParams(std::string cluster_id, std::string backup_id,
- std::string table_id,
- std::chrono::system_clock::time_point expire_time)
- : cluster_id(std::move(cluster_id)),
- backup_id(std::move(backup_id)),
- table_name(std::move(table_id)),
- expire_time(std::move(expire_time)) {}
-
- google::bigtable::admin::v2::CreateBackupRequest AsProto(
- std::string instance_name) const;
-
- std::string cluster_id;
- std::string backup_id;
- std::string table_name;
- std::chrono::system_clock::time_point expire_time;
- };
-
- /**
- * Create a new backup of a table in the instance.
- *
- * @param params instance of `CreateBackupParams`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc create backup
- */
- StatusOr CreateBackup(
- CreateBackupParams const& params);
-
- /**
- * Get information about a single backup.
- *
- * @param cluster_id the name of the cluster relative to the instance managed
- * by the `TableAdmin` object. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param backup_id the name of the backup relative to the cluster specified.
- * The full backup name is
- * `projects//instances//clusters//backups/`
- * where PROJECT_ID is obtained from the associated AdminClient,
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
- * CLUSTER_ID is the cluster_id previously specified.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc get backup
- */
- StatusOr GetBackup(
- std::string const& cluster_id, std::string const& backup_id);
-
- /**
- * Parameters for `UpdateBackup`.
- *
- * @param cluster_id the name of the cluster relative to the instance managed
- * by the `TableAdmin` object. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param backup_id the name of the backup relative to the cluster specified.
- * The full backup name is
- * `projects//instances//clusters//backups/`
- * where PROJECT_ID is obtained from the associated AdminClient,
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
- * CLUSTER_ID is the cluster_id specified for this object.
- * @param expire_time the date and time when the created backup will expire.
- */
- struct UpdateBackupParams {
- UpdateBackupParams() = default;
- UpdateBackupParams(std::string cluster_id, std::string backup_id,
- std::chrono::system_clock::time_point expire_time)
- : cluster_id(std::move(cluster_id)),
- backup_name(std::move(backup_id)),
- expire_time(std::move(expire_time)) {}
-
- google::bigtable::admin::v2::UpdateBackupRequest AsProto(
- std::string const& instance_name) const;
-
- std::string cluster_id;
- std::string backup_name;
- std::chrono::system_clock::time_point expire_time;
- };
-
- /**
- * Updates a backup of a table in the instance.
- *
- * @param params instance of `UpdateBackupParams`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc update backup
- */
- StatusOr UpdateBackup(
- UpdateBackupParams const& params);
-
- /**
- * Delete a backup.
- *
- * @param cluster_id the name of the cluster relative to the instance managed
- * by the `TableAdmin` object. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param backup_id the name of the backup relative to the cluster specified.
- * The full backup name is
- * `projects//instances//clusters//backups/`
- * where PROJECT_ID is obtained from the associated AdminClient,
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
- * CLUSTER_ID is the cluster_id previously specified.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc delete backup
- */
- Status DeleteBackup(std::string const& cluster_id,
- std::string const& backup_id);
-
- /**
- * Delete a backup.
- *
- * @param backup typically returned by a call to `GetBackup` or `ListBackups`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc delete backup
- */
- Status DeleteBackup(google::bigtable::admin::v2::Backup const& backup);
-
- /**
- * Parameters for `ListBackups`.
- */
- struct ListBackupsParams {
- /**
- * Sets the cluster_id.
- *
- * @param c the name of the cluster relative to the instance
- * managed by the `TableAdmin` object. If no cluster_id is specified,
- * the all backups in all clusters are listed. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- */
- ListBackupsParams& set_cluster(std::string c) {
- this->cluster_id = std::move(c);
- return *this;
- }
-
- /**
- * Sets the filtering expression.
- *
- * @param f expression that filters backups listed in the response.
- * The expression must specify the field name, a comparison operator,
- * and the value that you want to use for filtering. The value must be a
- * string, a number, or a boolean. The comparison operator must be
- * <, >, <=, >=, !=, =, or :. Colon ‘:’ represents a HAS operator which
- * is roughly synonymous with equality. Filter rules are case
- * insensitive.
- *
- * The fields eligible for filtering are:
- * * `name`
- * * `table`
- * * `state`
- * * `start_time` (and values are of the format
- * `YYYY-MM-DDTHH:MM:SSZ`)
- * * `end_time` (and values are of the format `YYYY-MM-DDTHH:MM:SSZ`)
- * * `expire_time` (and values are of the format
- * `YYYY-MM-DDTHH:MM:SSZ`)
- * * `size_bytes`
- *
- * To filter on multiple expressions, provide each separate expression
- * within parentheses. By default, each expression is an AND expression.
- * However, you can include AND, OR, and NOT expressions explicitly.
- *
- * Some examples of using filters are:
- * * `name:"exact"` --> The backup's name is the string "exact".
- * * `name:howl` --> The backup's name contains the string "howl".
- * * `table:prod` --> The table's name contains the string "prod".
- * * `state:CREATING` --> The backup is pending creation.
- * * `state:READY` --> The backup is fully created and ready for use.
- * * `(name:howl) AND (start_time < "2018-03-28T14:50:00Z")`
- * --> The backup name contains the string "howl" and start_time
- * of the backup is before `2018-03-28T14:50:00Z`.
- * * `size_bytes > 10000000000` --> The backup's size is greater than
- * 10GB
- */
- ListBackupsParams& set_filter(std::string f) {
- this->filter = std::move(f);
- return *this;
- }
-
- /**
- * Sets the ordering expression.
- *
- * @param o expression for specifying the sort order of the results
- * of the request. The string value should specify only one field in
- * `google::bigtable::admin::v2::Backup`.
- * The following field names are supported:
- * * name
- * * table
- * * expire_time
- * * start_time
- * * end_time
- * * size_bytes
- * * state
- *
- * For example, "start_time". The default sorting order is ascending.
- * Append the " desc" suffix to the field name to sort descending, e.g.
- * "start_time desc". Redundant space characters in the syntax are
- * insignificant.
- *
- * If order_by is empty, results will be sorted by `start_time` in
- * descending order starting from the most recently created backup.
- */
- ListBackupsParams& set_order_by(std::string o) {
- this->order_by = std::move(o);
- return *this;
- }
-
- google::bigtable::admin::v2::ListBackupsRequest AsProto(
- std::string const& instance_name) const;
-
- absl::optional cluster_id;
- absl::optional filter;
- absl::optional order_by;
- };
-
- /**
- * Retrieves a list of backups.
- *
- * @param params instance of `ListBackupsParams`.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc list backups
- */
- StatusOr> ListBackups(
- ListBackupsParams const& params);
-
- /**
- * Parameters for `RestoreTable`.
- *
- * @param table_id the name of the table relative to the instance managed by
- * this object. The full table name is
- * `projects//instances//tables/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of this object.
- * @param cluster_id the name of the cluster relative to the instance managed
- * by the `TableAdmin` object. The full cluster name is
- * `projects//instances//clusters/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object.
- * @param backup_id the name of the backup relative to the cluster specified.
- * The full backup name is
- * `projects//instances//clusters//backups/`
- * where PROJECT_ID is obtained from the associated AdminClient,
- * INSTANCE_ID is the instance_id() of the `TableAdmin` object, and
- * CLUSTER_ID is the cluster_id previously specified.
- */
- struct RestoreTableParams {
- RestoreTableParams() = default;
- RestoreTableParams(std::string table_id, std::string cluster_id,
- std::string backup_id)
- : table_id(std::move(table_id)),
- cluster_id(std::move(cluster_id)),
- backup_id(std::move(backup_id)) {}
-
- /// @deprecated covert the parameters to a proto.
- google::bigtable::admin::v2::RestoreTableRequest AsProto(
- std::string const& instance_name) const;
-
- std::string table_id;
- std::string cluster_id;
- std::string backup_id;
- };
-
- /**
- * Parameters for `RestoreTable`.
- *
- * @param table_id the name of the table relative to the instance managed by
- * this object. The full table name is
- * `projects//instances//tables/`
- * where PROJECT_ID is obtained from the associated AdminClient and
- * INSTANCE_ID is the instance_id() of this object.
- * @param backup_name the full name of the backup used to restore @p table_id.
- */
- struct RestoreTableFromInstanceParams {
- std::string table_id;
- std::string backup_name;
- };
-
- /**
- * Restore a backup into a new table in the instance.
- *
- * @param params instance of `RestoreTableParams`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc restore table
- */
- StatusOr RestoreTable(
- RestoreTableParams const& params);
-
- /**
- * Restore a backup into a new table in the instance.
- *
- * @param params instance of `RestoreTableFromInstanceParams`.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet bigtable_table_admin_backup_snippets.cc restore2
- */
- StatusOr RestoreTable(
- RestoreTableFromInstanceParams params);
-
- /**
- * Modify the schema for an existing table.
- *
- * @param table_id the id of the table within the instance associated with
- * this object. The full name of the table is
- * `this->instance_name() + "/tables/" + table_id`
- * @param modifications the list of modifications to the schema.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc modify table
- */
- StatusOr<::google::bigtable::admin::v2::Table> ModifyColumnFamilies(
- std::string const& table_id,
- std::vector modifications);
-
- /**
- * Delete all the rows that start with a given prefix.
- *
- * @param table_id the id of the table within the instance associated with
- * this object. The full name of the table is
- * `this->instance_name() + "/tables/" + table_id`
- * @param row_key_prefix drop any rows that start with this prefix.
- *
- * @par Idempotency
- * This operation is always treated as non-idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc drop rows by prefix
- */
- Status DropRowsByPrefix(std::string const& table_id,
- std::string row_key_prefix);
-
- /**
- * Generates consistency token for a table.
- *
- * @param table_id the id of the table for which we want to generate
- * consistency token.
- * @return the consistency token for table.
- *
- * @par Idempotency
- * This operation is read-only and therefore it is always idempotent.
- *
- * @par Thread-safety
- * Two threads concurrently calling this member function on the same instance
- * of this class are **not** guaranteed to work. Consider copying the object
- * and using different copies in each thread.
- *
- * @par Example
- * @snippet table_admin_snippets.cc generate consistency token
- */
- StatusOr