Google Cloud Bigtable C++ Client  0.11.0
A C++ Client Library for Google Cloud Bigtable
Public Member Functions | List of all members
google::cloud::bigtable::v0::InstanceAdmin Class Reference

Implements the APIs to administer Cloud Bigtable instances. More...

#include <google/cloud/bigtable/instance_admin.h>

Public Member Functions

 InstanceAdmin (std::shared_ptr< InstanceAdminClient > client)
 
template<typename... Policies>
 InstanceAdmin (std::shared_ptr< InstanceAdminClient > client, Policies &&... policies)
 Create a new InstanceAdmin using explicit policies to handle RPC errors. More...
 
std::string const & project_name () const
 The full name (projects/<project_id>) of the project. More...
 
std::string const & project_id () const
 The project id, i.e., project_name() without the projects/ prefix. More...
 
std::string InstanceName (std::string const &instance_id) const
 Return the fully qualified name of the given instance_id. More...
 
std::string ClusterName (std::string const &instance_id, std::string const &cluster_id) const
 Return the fully qualified name of the given cluster_id in give instance_id. More...
 
future< StatusOr< google::bigtable::admin::v2::Instance > > CreateInstance (InstanceConfig instance_config)
 Create a new instance of Cloud Bigtable. More...
 
future< StatusOr< google::bigtable::admin::v2::Instance > > AsyncCreateInstance (CompletionQueue &cq, bigtable::InstanceConfig instance_config)
 Create an instance (asynchronously). More...
 
future< StatusOr< google::bigtable::admin::v2::Cluster > > CreateCluster (ClusterConfig cluster_config, std::string const &instance_id, std::string const &cluster_id)
 Create a new Cluster of Cloud Bigtable. More...
 
future< StatusOr< google::bigtable::admin::v2::Cluster > > AsyncCreateCluster (CompletionQueue &cq, ClusterConfig cluster_config, std::string const &instance_id, std::string const &cluster_id)
 Create a new cluster (asynchronously). More...
 
future< StatusOr< google::bigtable::admin::v2::Instance > > UpdateInstance (InstanceUpdateConfig instance_update_config)
 Update an existing instance of Cloud Bigtable. More...
 
future< StatusOr< google::bigtable::admin::v2::Instance > > AsyncUpdateInstance (CompletionQueue &cq, InstanceUpdateConfig instance_update_config)
 Update an existing instance (asynchronously). More...
 
StatusOr< InstanceListListInstances ()
 Obtain the list of instances in the project. More...
 
future< StatusOr< InstanceList > > AsyncListInstances (CompletionQueue &cq)
 Query (asynchronously) the list of instances in the project. More...
 
StatusOr< google::bigtable::admin::v2::Instance > GetInstance (std::string const &instance_id)
 Return the details of instance_id. More...
 
future< StatusOr< google::bigtable::admin::v2::Instance > > AsyncGetInstance (CompletionQueue &cq, std::string const &instance_id)
 Sends an asynchronous request to get information about an existing instance. More...
 
Status DeleteInstance (std::string const &instance_id)
 Deletes the instances in the project. More...
 
future< Status > AsyncDeleteInstance (std::string const &instance_id, CompletionQueue &cq)
 Makes an asynchronous request to delete an instance. More...
 
StatusOr< ClusterListListClusters ()
 Obtain the list of clusters in an instance. More...
 
StatusOr< ClusterListListClusters (std::string const &instance_id)
 Obtain the list of clusters in an instance. More...
 
future< StatusOr< ClusterList > > AsyncListClusters (CompletionQueue &cq)
 Query (asynchronously) the list of clusters in a project. More...
 
future< StatusOr< ClusterList > > AsyncListClusters (CompletionQueue &cq, std::string const &instance_id)
 Query (asynchronously) the list of clusters in an instance. More...
 
future< StatusOr< google::bigtable::admin::v2::Cluster > > UpdateCluster (ClusterConfig cluster_config)
 Update an existing cluster of Cloud Bigtable. More...
 
future< StatusOr< google::bigtable::admin::v2::Cluster > > AsyncUpdateCluster (CompletionQueue &cq, ClusterConfig cluster_config)
 Update an existing cluster (asynchronously). More...
 
Status DeleteCluster (std::string const &instance_id, std::string const &cluster_id)
 Deletes the specified cluster of an instance in the project. More...
 
future< Status > AsyncDeleteCluster (CompletionQueue &cq, std::string const &instance_id, std::string const &cluster_id)
 Sends an asynchronous request to delete a cluster. More...
 
StatusOr< google::bigtable::admin::v2::Cluster > GetCluster (std::string const &instance_id, std::string const &cluster_id)
 Gets the specified cluster of an instance in the project. More...
 
future< StatusOr< google::bigtable::admin::v2::Cluster > > AsyncGetCluster (CompletionQueue &cq, std::string const &instance_id, std::string const &cluster_id)
 Sends an asynchronous request to get information about existing cluster of an instance. More...
 
StatusOr< google::bigtable::admin::v2::AppProfile > CreateAppProfile (std::string const &instance_id, AppProfileConfig config)
 Create a new application profile. More...
 
future< StatusOr< google::bigtable::admin::v2::AppProfile > > AsyncCreateAppProfile (CompletionQueue &cq, std::string const &instance_id, AppProfileConfig config)
 Asynchronously create a new application profile. More...
 
StatusOr< google::bigtable::admin::v2::AppProfile > GetAppProfile (std::string const &instance_id, std::string const &profile_id)
 Fetch the detailed information about an existing application profile. More...
 
future< StatusOr< google::bigtable::admin::v2::AppProfile > > AsyncGetAppProfile (CompletionQueue &cq, std::string const &instance_id, std::string const &profile_id)
 Asynchronously fetch the information about an existing application profile. More...
 
future< StatusOr< google::bigtable::admin::v2::AppProfile > > UpdateAppProfile (std::string const &instance_id, std::string const &profile_id, AppProfileUpdateConfig config)
 Updates an existing application profile. More...
 
future< StatusOr< google::bigtable::admin::v2::AppProfile > > AsyncUpdateAppProfile (CompletionQueue &cq, std::string const &instance_id, std::string const &profile_id, AppProfileUpdateConfig config)
 Updates an application profile (asynchronously). More...
 
StatusOr< std::vector< google::bigtable::admin::v2::AppProfile > > ListAppProfiles (std::string const &instance_id)
 List the application profiles in an instance. More...
 
future< StatusOr< std::vector< google::bigtable::admin::v2::AppProfile > > > AsyncListAppProfiles (CompletionQueue &cq, std::string const &instance_id)
 Query (asynchronously) the list of app profiles in an instance. More...
 
Status DeleteAppProfile (std::string const &instance_id, std::string const &profile_id, bool ignore_warnings=true)
 Delete an existing application profile. More...
 
future< Status > AsyncDeleteAppProfile (CompletionQueue &cq, std::string const &instance_id, std::string const &profile_id, bool ignore_warnings=true)
 Asynchronously delete an existing application profile. More...
 
StatusOr< google::cloud::IamPolicy > GetIamPolicy (std::string const &instance_id)
 Gets the policy for instance_id. More...
 
future< StatusOr< google::cloud::IamPolicy > > AsyncGetIamPolicy (CompletionQueue &cq, std::string const &instance_id)
 Asynchronously gets the policy for instance_id. More...
 
StatusOr< google::cloud::IamPolicy > SetIamPolicy (std::string const &instance_id, google::cloud::IamBindings const &iam_bindings, std::string const &etag=std::string{})
 Sets the IAM policy for an instance. More...
 
future< StatusOr< google::cloud::IamPolicy > > AsyncSetIamPolicy (CompletionQueue &cq, std::string const &instance_id, google::cloud::IamBindings const &iam_bindings, std::string const &etag=std::string{})
 Asynchronously sets the IAM policy for an instance. More...
 
StatusOr< std::vector< std::string > > TestIamPermissions (std::string const &instance_id, std::vector< std::string > const &permissions)
 Returns a permission set that the caller has on the specified instance. More...
 
future< StatusOr< std::vector< std::string > > > AsyncTestIamPermissions (CompletionQueue &cq, std::string const &instance_id, std::vector< std::string > const &permissions)
 Asynchronously obtains a permission set that the caller has on the specified instance. More...
 

Detailed Description

Implements the APIs to administer Cloud Bigtable instances.

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 on the same instance of this class is not guaranteed to work.
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<int>. The class represents a shallow handle to a remote object.
Error Handling
This class uses StatusOr<T> to report errors. When an operation fails to perform its work the returned StatusOr<T> contains the error details. If the ok() member function in the StatusOr<T> 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<T> documentation for more details.
namespace btadmin = google::bigtable::admin::v2;
cbt::TableAdmin admin = ...;
google::cloud::StatusOr<btadmin::Table> 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";

In addition, the main page contains examples using StatusOr<T> to handle errors.

Retry, Backoff, and Idempotency Policies
The library automatically retries requests that fail with transient errors, and uses truncated exponential backoff 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.

See also
https://cloud.google.com/bigtable/ for an overview of Cloud Bigtable.
https://cloud.google.com/bigtable/docs/overview for an overview of the Cloud Bigtable data model.
https://cloud.google.com/bigtable/docs/instances-clusters-nodes for an introduction of the main APIs into Cloud Bigtable.
https://cloud.google.com/bigtable/docs/reference/service-apis-overview for an overview of the underlying Cloud Bigtable API.
google::cloud::v0::StatusOr for a description of the error reporting class used by this library.
LimitedTimeRetryPolicy and LimitedErrorCountRetryPolicy for alternative retry policies.
ExponentialBackoffPolicy to configure different parameters for the exponential backoff policy.
SafeIdempotentMutationPolicy and AlwaysRetryMutationPolicy for alternative idempotency policies.

Definition at line 121 of file instance_admin.h.

Constructor & Destructor Documentation

◆ InstanceAdmin() [1/2]

google::cloud::bigtable::v0::InstanceAdmin::InstanceAdmin ( std::shared_ptr< InstanceAdminClient client)
inlineexplicit
Parameters
clientthe interface to create grpc stubs, report errors, etc.

Definition at line 126 of file instance_admin.h.

◆ InstanceAdmin() [2/2]

template<typename... Policies>
google::cloud::bigtable::v0::InstanceAdmin::InstanceAdmin ( std::shared_ptr< InstanceAdminClient client,
Policies &&...  policies 
)
inlineexplicit

Create a new InstanceAdmin using explicit policies to handle RPC errors.

Parameters
clientthe interface to create grpc stubs, report errors, etc.
policiesthe set of policy overrides for this object.
Template Parameters
Policiesthe 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 also
GenericPollingPolicy, ExponentialBackoffPolicy, LimitedErrorCountRetryPolicy, LimitedTimeRetryPolicy.

Definition at line 161 of file instance_admin.h.

Member Function Documentation

◆ AsyncCreateAppProfile()

future< StatusOr< google::bigtable::admin::v2::AppProfile > > google::cloud::bigtable::v0::InstanceAdmin::AsyncCreateAppProfile ( CompletionQueue cq,
std::string const &  instance_id,
AppProfileConfig  config 
)

Asynchronously create a new application profile.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance for the new application profile.
configthe configuration for the new application profile.
Returns
The proto describing the new application profile.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string profile_id) {
cbt::AppProfileConfig config =
cbt::AppProfileConfig::MultiClusterUseAny(profile_id);
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.AsyncCreateAppProfile(cq, instance_id, config);
// Show how to perform additional work while the long running operation
// completes. The application could use profile_future.then() instead.
std::cout << "Waiting for app_profile creation to complete " << std::flush;
profile_future.wait_for(std::chrono::seconds(2));
std::cout << '.' << std::flush;
auto app_profile = profile_future.get();
if (!app_profile) {
throw std::runtime_error(app_profile.status().message());
}
std::cout << "DONE, details=" << app_profile->DebugString() << "\n";
}

Definition at line 542 of file instance_admin.cc.

◆ AsyncCreateCluster()

future< StatusOr< google::bigtable::admin::v2::Cluster > > google::cloud::bigtable::v0::InstanceAdmin::AsyncCreateCluster ( CompletionQueue cq,
ClusterConfig  cluster_config,
std::string const &  instance_id,
std::string const &  cluster_id 
)

Create a new cluster (asynchronously).

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
cluster_configa description of the new cluster to be created.
instance_idthe id of the instance in the project
cluster_idthe id of the cluster in the project that needs to be created. It must be between 6 and 30 characters.
Returns
a future satisfied when either (a) the cluster is created or (b) a permanent error occurs or (c) polling or retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string cluster_id, std::string zone) {
cbt::ClusterConfig cluster_config =
cbt::ClusterConfig(zone, 3, cbt::ClusterConfig::HDD);
future<StatusOr<google::bigtable::admin::v2::Cluster>> cluster_future =
instance_admin.AsyncCreateCluster(cq, cluster_config, instance_id,
cluster_id);
// Show how to perform additional work while the long running operation
// completes. The application could use future.then() instead.
std::cout << "Waiting for cluster creation to complete " << std::flush;
cluster_future.wait_for(std::chrono::seconds(2));
std::cout << '.' << std::flush;
auto cluster = cluster_future.get();
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
std::cout << "DONE, details=" << cluster->DebugString() << "\n";
}

Definition at line 179 of file instance_admin.cc.

◆ AsyncCreateInstance()

future< StatusOr< google::bigtable::admin::v2::Instance > > google::cloud::bigtable::v0::InstanceAdmin::AsyncCreateInstance ( CompletionQueue cq,
bigtable::InstanceConfig  instance_config 
)

Create an instance (asynchronously).

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_configthe desired configuration of the instance.
Returns
a future satisfied when either (a) the cluster is created or (b) a permanent error occurs or (c) polling or retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string zone) {
std::string display_name("Put description here");
std::string cluster_id = instance_id + "-c1";
cbt::ClusterConfig cluster_config =
cbt::ClusterConfig(zone, 3, cbt::ClusterConfig::HDD);
cbt::InstanceConfig config(instance_id, display_name,
{{cluster_id, cluster_config}});
config.set_type(cbt::InstanceConfig::PRODUCTION);
future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
instance_admin.AsyncCreateInstance(cq, config);
// Show how to perform additional work while the long running operation
// completes. The application could use future.then() instead.
std::cout << "Waiting for instance creation to complete " << std::flush;
instance_future.wait_for(std::chrono::seconds(2));
std::cout << '.' << std::flush;
auto instance = instance_future.get();
if (!instance) {
throw std::runtime_error(instance.status().message());
}
std::cout << "DONE, details=" << instance->name() << "\n";
}

Definition at line 141 of file instance_admin.cc.

◆ AsyncDeleteAppProfile()

future< Status > google::cloud::bigtable::v0::InstanceAdmin::AsyncDeleteAppProfile ( CompletionQueue cq,
std::string const &  instance_id,
std::string const &  profile_id,
bool  ignore_warnings = true 
)

Asynchronously delete an existing application profile.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance to look the profile in.
profile_idthe id of the profile within that instance.
ignore_warningsif 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.
Returns
a future satisfied when either (a) the app profile is deleted or (b) an unretriable error occurs or (c) retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string app_profile_id) {
future<google::cloud::Status> status_future =
instance_admin.AsyncDeleteAppProfile(cq, instance_id, app_profile_id,
/*ignore_warnings=*/true);
google::cloud::Status status = status_future.get();
if (!status.ok()) {
throw std::runtime_error(status.message());
}
std::cout << "Profile " << app_profile_id << " successfully deleted\n";
}

Definition at line 710 of file instance_admin.cc.

◆ AsyncDeleteCluster()

future< Status > google::cloud::bigtable::v0::InstanceAdmin::AsyncDeleteCluster ( CompletionQueue cq,
std::string const &  instance_id,
std::string const &  cluster_id 
)

Sends an asynchronous request to delete a cluster.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe id of the instance in the project.
cluster_idthe id of the cluster in the project that needs to be deleted.
Returns
a future that will be satisfied when the request succeeds or the retry policy expires.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string cluster_id) {
future<google::cloud::Status> status_future =
instance_admin.AsyncDeleteCluster(cq, instance_id, cluster_id);
google::cloud::Status status = status_future.get();
if (!status.ok()) {
throw std::runtime_error(status.message());
}
std::cout << "Cluster " << cluster_id << " successfully deleted\n";
}

Definition at line 289 of file instance_admin.cc.

◆ AsyncDeleteInstance()

future< Status > google::cloud::bigtable::v0::InstanceAdmin::AsyncDeleteInstance ( std::string const &  instance_id,
CompletionQueue cq 
)

Makes an asynchronous request to delete an instance.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
instance_idthe id of the instance in the project to be deleted.
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id) {
future<google::cloud::Status> status_future =
instance_admin.AsyncDeleteInstance(instance_id, cq);
google::cloud::Status status = status_future.get();
if (!status.ok()) {
throw std::runtime_error(status.message());
}
std::cout << "Instance " << instance_id << " successfully deleted\n";
}

Definition at line 315 of file instance_admin.cc.

◆ AsyncGetAppProfile()

future< StatusOr< google::bigtable::admin::v2::AppProfile > > google::cloud::bigtable::v0::InstanceAdmin::AsyncGetAppProfile ( CompletionQueue cq,
std::string const &  instance_id,
std::string const &  profile_id 
)

Asynchronously fetch the information about an existing application profile.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance to look the profile in.
profile_idthe id of the profile within that instance.
Returns
a future satisfied when either (a) the profile is fetched or (b) an unretriable error occurs or (c) retry policy has been exhausted.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string app_profile_id) {
future<void> final =
instance_admin.AsyncGetAppProfile(cq, instance_id, app_profile_id)
.then([](google::cloud::future<
StatusOr<google::bigtable::admin::v2::AppProfile>>
f) {
StatusOr<google::bigtable::admin::v2::AppProfile> app_profile =
f.get();
if (!app_profile) {
throw std::runtime_error(app_profile.status().message());
}
std::string app_profile_detail;
google::protobuf::TextFormat::PrintToString(*app_profile,
&app_profile_detail);
std::cout << "GetAppProfile details : " << app_profile_detail
<< "\n";
});
final.get(); // block to keep the example simple
}

Definition at line 579 of file instance_admin.cc.

◆ AsyncGetCluster()

future< StatusOr< btadmin::Cluster > > google::cloud::bigtable::v0::InstanceAdmin::AsyncGetCluster ( CompletionQueue cq,
std::string const &  instance_id,
std::string const &  cluster_id 
)

Sends an asynchronous request to get information about existing cluster of an instance.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
instance_idthe id of the instance in the project.
cluster_idthe id of the cluster in the project that needs to be retrieved.
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
Returns
a future that will be satisfied when the request succeeds or the retry policy expires. In the first case, the future will contain the response from the service. In the second the future is satisfied with an exception.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string cluster_id) {
future<StatusOr<google::bigtable::admin::v2::Cluster>> cluster_future =
instance_admin.AsyncGetCluster(cq, instance_id, cluster_id);
future<google::cloud::Status> final = cluster_future.then(
[](google::cloud::future<
google::cloud::StatusOr<google::bigtable::admin::v2::Cluster>>
f) {
StatusOr<google::bigtable::admin::v2::Cluster> cluster = f.get();
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
std::string cluster_detail;
google::protobuf::TextFormat::PrintToString(*cluster,
&cluster_detail);
std::cout << "GetCluster details : " << cluster_detail << "\n";
return google::cloud::Status();
});
final.get(); // block to keep the example simple
}

Definition at line 357 of file instance_admin.cc.

◆ AsyncGetIamPolicy()

future< StatusOr< google::cloud::IamPolicy > > google::cloud::bigtable::v0::InstanceAdmin::AsyncGetIamPolicy ( CompletionQueue cq,
std::string const &  instance_id 
)

Asynchronously gets the policy for instance_id.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance to query.
Returns
a future satisfied when either (a) the policy is fetched or (b) an unretriable error occurs or (c) retry policy has been exhausted.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id) {
future<StatusOr<google::cloud::IamPolicy>> policy_future =
instance_admin.AsyncGetIamPolicy(cq, instance_id);
future<void> final = policy_future.then(
[](google::cloud::future<StatusOr<google::cloud::IamPolicy>> f) {
StatusOr<google::cloud::IamPolicy> iam_policy = f.get();
if (!iam_policy) {
throw std::runtime_error(iam_policy.status().message());
}
std::cout << "IamPolicy details : " << *iam_policy << "\n";
});
final.get(); // block to keep the example simple
}

Definition at line 761 of file instance_admin.cc.

◆ AsyncGetInstance()

future< StatusOr< btadmin::Instance > > google::cloud::bigtable::v0::InstanceAdmin::AsyncGetInstance ( CompletionQueue cq,
std::string const &  instance_id 
)

Sends an asynchronous request to get information about an existing instance.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
instance_idthe id of the instance in the project that to be retrieved.
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
Returns
a future that will be satisfied when the request succeeds or the retry policy expires. In the first case, the future will contain the response from the service. In the second the future is satisfied with an exception.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id) {
future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
instance_admin.AsyncGetInstance(cq, instance_id);
future<google::cloud::Status> final = instance_future.then(
[](future<StatusOr<google::bigtable::admin::v2::Instance>> f) {
auto instance = f.get();
if (!instance) {
throw std::runtime_error(instance.status().message());
}
std::cout << "GetInstance details : " << instance->DebugString()
<< "\n";
return google::cloud::Status();
});
final.get(); // block to keep the example simple
}

Definition at line 258 of file instance_admin.cc.

◆ AsyncListAppProfiles()

future< StatusOr< std::vector< btadmin::AppProfile > > > google::cloud::bigtable::v0::InstanceAdmin::AsyncListAppProfiles ( CompletionQueue cq,
std::string const &  instance_id 
)

Query (asynchronously) the list of app profiles in an instance.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance in a project.
Returns
the list of app profiles.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<cbt::ClusterList> cluster_list =
instance_admin.ListClusters(instance_id);
if (!cluster_list) {
throw std::runtime_error(cluster_list.status().message());
}
std::cout << "Cluster Name List\n";
for (auto const& cluster : cluster_list->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!cluster_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about clusters in these locations can be obtained:\n";
for (auto const& failed_location : cluster_list->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 670 of file instance_admin.cc.

◆ AsyncListClusters() [1/2]

future< StatusOr< ClusterList > > google::cloud::bigtable::v0::InstanceAdmin::AsyncListClusters ( CompletionQueue cq)

Query (asynchronously) the list of clusters in a project.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
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.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
Returns
the list of clusters. It is possible that some zones are not currently available for querying. In that case this function returns the list of failed locations in the projects/<project>/locations/<zone_id> format.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<cbt::ClusterList> cluster_list =
instance_admin.ListClusters(instance_id);
if (!cluster_list) {
throw std::runtime_error(cluster_list.status().message());
}
std::cout << "Cluster Name List\n";
for (auto const& cluster : cluster_list->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!cluster_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about clusters in these locations can be obtained:\n";
for (auto const& failed_location : cluster_list->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 425 of file instance_admin.cc.

◆ AsyncListClusters() [2/2]

future< StatusOr< ClusterList > > google::cloud::bigtable::v0::InstanceAdmin::AsyncListClusters ( CompletionQueue cq,
std::string const &  instance_id 
)

Query (asynchronously) 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.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance in a project.
Returns
the list of clusters. It is possible that some zones are not currently available for querying. In that case this function returns the list of failed locations in the projects/<project>/locations/<zone_id> format.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<cbt::ClusterList> cluster_list =
instance_admin.ListClusters(instance_id);
if (!cluster_list) {
throw std::runtime_error(cluster_list.status().message());
}
std::cout << "Cluster Name List\n";
for (auto const& cluster : cluster_list->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!cluster_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about clusters in these locations can be obtained:\n";
for (auto const& failed_location : cluster_list->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 430 of file instance_admin.cc.

◆ AsyncListInstances()

future< StatusOr< InstanceList > > google::cloud::bigtable::v0::InstanceAdmin::AsyncListInstances ( CompletionQueue cq)

Query (asynchronously) the list of instances in the project.

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
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.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
Returns
the list of instances. It is possible that some zones are not currently available for querying. In that case this function returns the list of failed locations in the projects/<project>/locations/<zone_id> format.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq) {
future<google::cloud::StatusOr<cbt::InstanceList>> instances_future =
instance_admin.AsyncListInstances(cq);
future<void> final =
instances_future.then([](future<StatusOr<cbt::InstanceList>> f) {
auto instance_list = f.get();
if (!instance_list) {
throw std::runtime_error(instance_list.status().message());
}
for (const auto& instance : instance_list->instances) {
std::cout << instance.name() << "\n";
}
if (!instance_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that it could not "
"retrieve data for the following zones:\n";
for (const auto& failed_location :
instance_list->failed_locations) {
std::cout << failed_location << "\n";
}
std::cout << "This is typically a transient condition, try again "
"later.\n";
}
});
final.get(); // block to keep the example simple
}

Definition at line 81 of file instance_admin.cc.

◆ AsyncSetIamPolicy()

future< StatusOr< google::cloud::IamPolicy > > google::cloud::bigtable::v0::InstanceAdmin::AsyncSetIamPolicy ( CompletionQueue cq,
std::string const &  instance_id,
google::cloud::IamBindings const &  iam_bindings,
std::string const &  etag = std::string{} 
)

Asynchronously sets the IAM policy for an instance.

Applications can provide the etag to implement optimistic concurrency control. If etag is not empty, the server will reject calls where the provided ETag does not match the ETag value stored in the server.

Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idwhich instance to set the IAM policy for.
iam_bindingsIamBindings object containing role and members.
etagthe expected ETag value for the current policy.
Returns
a future satisfied when either (a) the policy is created or (b) an unretriable error occurs or (c) retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::IamPolicy;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string role, std::string member) {
future<StatusOr<IamPolicy>> updated_future =
instance_admin.AsyncGetIamPolicy(cq, instance_id)
.then([cq, instance_admin, role, member, instance_id](
future<StatusOr<IamPolicy>> current_future) mutable {
auto current = current_future.get();
if (!current) {
return google::cloud::make_ready_future<StatusOr<IamPolicy>>(
current.status());
}
google::cloud::IamBindings bindings = current->bindings;
bindings.AddMember(role, member);
return instance_admin.AsyncSetIamPolicy(cq, instance_id, bindings,
current->etag);
});
// Show how to perform additional work while the long running operation
// completes. The application could use future.then() instead.
std::cout << "Waiting for IAM policy update to complete " << std::flush;
updated_future.wait_for(std::chrono::seconds(2));
auto result = updated_future.get();
std::cout << '.' << std::flush;
if (!result) {
throw std::runtime_error(result.status().message());
}
std::cout << "DONE, the IAM Policy for " << instance_id << " is\n";
for (auto const& kv : result->bindings) {
std::cout << "role " << kv.first << " includes [";
char const* sep = "";
for (auto const& m : kv.second) {
std::cout << sep << m;
sep = ", ";
}
std::cout << "]\n";
}
}

Definition at line 824 of file instance_admin.cc.

◆ AsyncTestIamPermissions()

future< StatusOr< std::vector< std::string > > > google::cloud::bigtable::v0::InstanceAdmin::AsyncTestIamPermissions ( CompletionQueue cq,
std::string const &  instance_id,
std::vector< std::string > const &  permissions 
)

Asynchronously obtains a permission set that the caller has on the specified instance.

Idempotency
This operation is read-only and therefore it is always idempotent.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe ID of the instance to query.
permissionsset of permissions to check for the resource.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string resource, std::vector<std::string>(permissions)) {
future<StatusOr<std::vector<std::string>>> permissions_future =
instance_admin.AsyncTestIamPermissions(cq, resource, permissions);
// Show how to perform additional work while the long running operation
// completes. The application could use permissions_future.then() instead.
std::cout << "Waiting for app profile update to complete " << std::flush;
permissions_future.wait_for(std::chrono::seconds(2));
std::cout << '.' << std::flush;
auto result = permissions_future.get();
if (!result) {
throw std::runtime_error(result.status().message());
}
std::cout << "DONE, the current user has the following permissions [";
char const* sep = "";
for (auto const& p : *result) {
std::cout << sep << p;
sep = ", ";
}
std::cout << "]\n";
}
See also
https://cloud.google.com/bigtable/docs/access-control for a list of valid permissions on Google Cloud Bigtable.

Definition at line 900 of file instance_admin.cc.

◆ AsyncUpdateAppProfile()

future< StatusOr< google::bigtable::admin::v2::AppProfile > > google::cloud::bigtable::v0::InstanceAdmin::AsyncUpdateAppProfile ( CompletionQueue cq,
std::string const &  instance_id,
std::string const &  profile_id,
AppProfileUpdateConfig  config 
)

Updates an application profile (asynchronously).

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_idthe instance for the new application profile.
profile_idthe id (not the full name) of the profile to update.
configthe configuration for the new application profile.
Returns
a future satisfied when either (a) the profile is updated or (b) an unretriable error occurs or (c) polling or retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string profile_id) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.AsyncUpdateAppProfile(
cq, instance_id, profile_id,
cbt::AppProfileUpdateConfig()
.set_description("new description")
.set_ignore_warnings(true));
// Show how to perform additional work while the long running operation
// completes. The application could use profile_future.then() instead.
std::cout << "Waiting for app profile update to complete " << std::flush;
profile_future.wait_for(std::chrono::seconds(2));
std::cout << '.' << std::flush;
auto app_profile = profile_future.get();
if (!app_profile) {
throw std::runtime_error(app_profile.status().message());
}
std::cout << "DONE, details=" << app_profile->DebugString() << "\n";
}

Definition at line 611 of file instance_admin.cc.

◆ AsyncUpdateCluster()

future< StatusOr< google::bigtable::admin::v2::Cluster > > google::cloud::bigtable::v0::InstanceAdmin::AsyncUpdateCluster ( CompletionQueue cq,
ClusterConfig  cluster_config 
)

Update an existing cluster (asynchronously).

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
cluster_configcluster with updated values.
Returns
a future satisfied when either (a) the cluster is updated or (b) an unretriable error occurs or (c) polling or retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id, std::string cluster_id) {
future<void> final =
instance_admin.AsyncGetCluster(cq, instance_id, cluster_id)
.then([instance_admin,
cq](future<StatusOr<google::bigtable::admin::v2::Cluster>>
f) mutable {
auto cluster = f.get();
if (!cluster) {
return google::cloud::make_ready_future(
StatusOr<google::bigtable::admin::v2::Cluster>(
cluster.status()));
}
// The state cannot be sent on updates, so clear it first.
cluster->clear_state();
// Set the desired cluster configuration.
cluster->set_serve_nodes(4);
cbt::ClusterConfig modified_config =
cbt::ClusterConfig(std::move(*cluster));
return instance_admin.AsyncUpdateCluster(cq, modified_config);
})
.then([](future<StatusOr<google::bigtable::admin::v2::Cluster>> f) {
auto cluster = f.get();
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
std::cout << "DONE, details=" << cluster->DebugString() << "\n";
});
final.get(); // block to keep example simple.
}

Definition at line 487 of file instance_admin.cc.

◆ AsyncUpdateInstance()

future< StatusOr< google::bigtable::admin::v2::Instance > > google::cloud::bigtable::v0::InstanceAdmin::AsyncUpdateInstance ( CompletionQueue cq,
InstanceUpdateConfig  instance_update_config 
)

Update an existing instance (asynchronously).

Warning
This is an early version of the asynchronous APIs for Cloud Bigtable. These APIs might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy.
Parameters
cqthe completion queue that will execute the asynchronous calls, the application must ensure that one or more threads are blocked on cq.Run().
instance_update_configconfig with modified instance.
Returns
a future satisfied when either (a) the instance is updated or (b) an unretriable error occurs or (c) polling or retry policy has been exhausted.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, cbt::CompletionQueue cq,
std::string instance_id) {
// Chain a AsyncGetInstance() + AsyncUpdateInstance().
future<void> final =
instance_admin.AsyncGetInstance(cq, instance_id)
.then([instance_admin,
cq](future<StatusOr<google::bigtable::admin::v2::Instance>>
f) mutable {
auto instance = f.get();
if (!instance) {
throw std::runtime_error(instance.status().message());
}
// Modify the instance and prepare the mask with modified
// field
cbt::InstanceUpdateConfig instance_update_config(
std::move(*instance));
instance_update_config.set_display_name("Modified Display Name");
return instance_admin.AsyncUpdateInstance(cq,
instance_update_config);
})
.then(
[](future<StatusOr<google::bigtable::admin::v2::Instance>> f) {
auto instance = f.get();
if (!instance) {
throw std::runtime_error(instance.status().message());
}
std::cout
<< "DONE, instance details: " << instance->DebugString()
<< "\n";
});
final.get(); // block to keep example simple.
}

Definition at line 217 of file instance_admin.cc.

◆ ClusterName()

std::string google::cloud::bigtable::v0::InstanceAdmin::ClusterName ( std::string const &  instance_id,
std::string const &  cluster_id 
) const
inline

Return the fully qualified name of the given cluster_id in give instance_id.

Definition at line 179 of file instance_admin.h.

◆ CreateAppProfile()

StatusOr< btadmin::AppProfile > google::cloud::bigtable::v0::InstanceAdmin::CreateAppProfile ( std::string const &  instance_id,
AppProfileConfig  config 
)

Create a new application profile.

Parameters
instance_idthe instance for the new application profile.
configthe configuration for the new application profile.
Returns
The proto describing the new application profile.
Idempotency
This operation is always treated as non-idempotent.
Multi-cluster Routing Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id) {
auto config = cbt::AppProfileConfig::MultiClusterUseAny(profile_id);
StatusOr<google::bigtable::admin::v2::AppProfile> profile =
instance_admin.CreateAppProfile(instance_id, config);
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "New profile created with name=" << profile->name() << "\n";
}
Single Cluster Routing Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id, std::string cluster_id) {
auto config =
cbt::AppProfileConfig::SingleClusterRouting(profile_id, cluster_id);
StatusOr<google::bigtable::admin::v2::AppProfile> profile =
instance_admin.CreateAppProfile(instance_id, config);
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "New profile created with name=" << profile->name() << "\n";
}

Definition at line 522 of file instance_admin.cc.

◆ CreateCluster()

future< StatusOr< btadmin::Cluster > > google::cloud::bigtable::v0::InstanceAdmin::CreateCluster ( ClusterConfig  cluster_config,
std::string const &  instance_id,
std::string const &  cluster_id 
)

Create a new Cluster of Cloud Bigtable.

Parameters
cluster_configa description of the new cluster to be created.
instance_idthe id of the instance in the project
cluster_idthe id of the cluster in the project that needs to be created. It must be between 6 and 30 characters.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string cluster_id, std::string zone) {
auto cluster_config = cbt::ClusterConfig(zone, 3, cbt::ClusterConfig::HDD);
future<StatusOr<google::bigtable::admin::v2::Cluster>> cluster_future =
instance_admin.CreateCluster(cluster_config, instance_id, cluster_id);
// Applications can wait asynchronously, in this example we just block.
auto cluster = cluster_future.get();
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
std::cout << "Successfully created cluster " << cluster->name() << "\n";
}

Definition at line 164 of file instance_admin.cc.

◆ CreateInstance()

future< StatusOr< btadmin::Instance > > google::cloud::bigtable::v0::InstanceAdmin::CreateInstance ( InstanceConfig  instance_config)

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.
Parameters
instance_configa 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.
Returns
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.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string zone) {
std::string display_name("Put description here");
std::string cluster_id = instance_id + "-c1";
auto cluster_config = cbt::ClusterConfig(zone, 3, cbt::ClusterConfig::HDD);
cbt::InstanceConfig config(instance_id, display_name,
{{cluster_id, cluster_config}});
config.set_type(cbt::InstanceConfig::PRODUCTION);
future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
instance_admin.CreateInstance(config);
// Show how to perform additional work while the long running operation
// completes. The application could use future.then() instead.
std::cout << "Waiting for instance creation to complete " << std::flush;
instance_future.wait_for(std::chrono::seconds(1));
std::cout << '.' << std::flush;
auto instance = instance_future.get();
if (!instance) {
throw std::runtime_error(instance.status().message());
}
std::cout << "DONE, details=" << instance->DebugString() << "\n";
}

Definition at line 128 of file instance_admin.cc.

◆ DeleteAppProfile()

Status google::cloud::bigtable::v0::InstanceAdmin::DeleteAppProfile ( std::string const &  instance_id,
std::string const &  profile_id,
bool  ignore_warnings = true 
)

Delete an existing application profile.

Parameters
instance_idthe instance to look the profile in.
profile_idthe id of the profile within that instance.
ignore_warningsif 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.
Idempotency
This operation is always treated as non-idempotent.
Example
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id, bool ignore_warnings) {
google::cloud::Status status = instance_admin.DeleteAppProfile(
instance_id, profile_id, ignore_warnings);
if (!status.ok()) {
throw std::runtime_error(status.message());
}
std::cout << "Application Profile deleted\n";
}

Definition at line 694 of file instance_admin.cc.

◆ DeleteCluster()

Status google::cloud::bigtable::v0::InstanceAdmin::DeleteCluster ( std::string const &  instance_id,
std::string const &  cluster_id 
)

Deletes the specified cluster of an instance in the project.

Parameters
instance_idthe id of the instance in the project
cluster_idthe id of the cluster in the project that needs to be deleted
Idempotency
This operation is always treated as non-idempotent.
Example
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string cluster_id) {
google::cloud::Status status =
instance_admin.DeleteCluster(instance_id, cluster_id);
if (!status.ok()) {
throw std::runtime_error(status.message());
}
}

Definition at line 505 of file instance_admin.cc.

◆ DeleteInstance()

Status google::cloud::bigtable::v0::InstanceAdmin::DeleteInstance ( std::string const &  instance_id)

Deletes the instances in the project.

Parameters
instance_idthe id of the instance in the project that needs to be deleted
Idempotency
This operation is always treated as non-idempotent.
Example
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
google::cloud::Status status = instance_admin.DeleteInstance(instance_id);
if (!status.ok()) {
throw std::runtime_error(status.message());
}
std::cout << "Successfully deleted the instance " << instance_id << "\n";
}

Definition at line 276 of file instance_admin.cc.

◆ GetAppProfile()

StatusOr< btadmin::AppProfile > google::cloud::bigtable::v0::InstanceAdmin::GetAppProfile ( std::string const &  instance_id,
std::string const &  profile_id 
)

Fetch the detailed information about an existing application profile.

Parameters
instance_idthe instance to look the profile in.
profile_idthe id of the profile within that instance.
Returns
The proto describing the application profile.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id) {
StatusOr<google::bigtable::admin::v2::AppProfile> profile =
instance_admin.GetAppProfile(instance_id, profile_id);
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "Application Profile details=" << profile->DebugString()
<< "\n";
}

Definition at line 561 of file instance_admin.cc.

◆ GetCluster()

StatusOr< btadmin::Cluster > google::cloud::bigtable::v0::InstanceAdmin::GetCluster ( std::string const &  instance_id,
std::string const &  cluster_id 
)

Gets the specified cluster of an instance in the project.

Parameters
instance_idthe id of the instance in the project
cluster_idthe id of the cluster in the project that needs to be deleted
Returns
a Cluster for given instance_id and cluster_id.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string cluster_id) {
StatusOr<google::bigtable::admin::v2::Cluster> cluster =
instance_admin.GetCluster(instance_id, cluster_id);
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
std::cout << "GetCluster details : " << cluster->DebugString() << "\n";
}

Definition at line 338 of file instance_admin.cc.

◆ GetIamPolicy()

StatusOr< google::cloud::IamPolicy > google::cloud::bigtable::v0::InstanceAdmin::GetIamPolicy ( std::string const &  instance_id)

Gets the policy for instance_id.

Parameters
instance_idthe instance to query.
Returns
Policy the full IAM policy for the instance.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<google::cloud::IamPolicy> policy =
instance_admin.GetIamPolicy(instance_id);
if (!policy) {
throw std::runtime_error(policy.status().message());
}
std::cout << "The IAM Policy for " << instance_id << " is\n";
for (auto const& kv : policy->bindings) {
std::cout << "role " << kv.first << " includes [";
char const* sep = "";
for (auto const& member : kv.second) {
std::cout << sep << member;
sep = ", ";
}
std::cout << "]\n";
}
}

Definition at line 737 of file instance_admin.cc.

◆ GetInstance()

StatusOr< btadmin::Instance > google::cloud::bigtable::v0::InstanceAdmin::GetInstance ( std::string const &  instance_id)

Return the details of instance_id.

Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<google::bigtable::admin::v2::Instance> instance =
instance_admin.GetInstance(instance_id);
if (!instance) {
throw std::runtime_error(instance.status().message());
}
std::cout << "GetInstance details : " << instance->DebugString() << "\n";
}

Definition at line 236 of file instance_admin.cc.

◆ InstanceName()

std::string google::cloud::bigtable::v0::InstanceAdmin::InstanceName ( std::string const &  instance_id) const
inline

Return the fully qualified name of the given instance_id.

Definition at line 173 of file instance_admin.h.

◆ ListAppProfiles()

StatusOr< std::vector< btadmin::AppProfile > > google::cloud::bigtable::v0::InstanceAdmin::ListAppProfiles ( std::string const &  instance_id)

List the application profiles in an instance.

Parameters
instance_idthe instance to list the profiles for.
Returns
a std::vector with the protos describing any profiles.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<std::vector<google::bigtable::admin::v2::AppProfile>> profiles =
instance_admin.ListAppProfiles(instance_id);
if (!profiles) {
throw std::runtime_error(profiles.status().message());
}
std::cout << "The " << instance_id << " instance has " << profiles->size()
<< " application profiles\n";
for (auto const& profile : *profiles) {
std::cout << profile.DebugString() << "\n";
}
}

Definition at line 634 of file instance_admin.cc.

◆ ListClusters() [1/2]

StatusOr< ClusterList > google::cloud::bigtable::v0::InstanceAdmin::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.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<cbt::ClusterList> cluster_list =
instance_admin.ListClusters(instance_id);
if (!cluster_list) {
throw std::runtime_error(cluster_list.status().message());
}
std::cout << "Cluster Name List\n";
for (auto const& cluster : cluster_list->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!cluster_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about clusters in these locations can be obtained:\n";
for (auto const& failed_location : cluster_list->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 377 of file instance_admin.cc.

◆ ListClusters() [2/2]

StatusOr< ClusterList > google::cloud::bigtable::v0::InstanceAdmin::ListClusters ( 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.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
StatusOr<cbt::ClusterList> cluster_list =
instance_admin.ListClusters(instance_id);
if (!cluster_list) {
throw std::runtime_error(cluster_list.status().message());
}
std::cout << "Cluster Name List\n";
for (auto const& cluster : cluster_list->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!cluster_list->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about clusters in these locations can be obtained:\n";
for (auto const& failed_location : cluster_list->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 381 of file instance_admin.cc.

◆ ListInstances()

StatusOr< InstanceList > google::cloud::bigtable::v0::InstanceAdmin::ListInstances ( )

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.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin) {
StatusOr<cbt::InstanceList> instances = instance_admin.ListInstances();
if (!instances) {
throw std::runtime_error(instances.status().message());
}
for (auto const& instance : instances->instances) {
std::cout << instance.name() << "\n";
}
if (!instances->failed_locations.empty()) {
std::cout << "The Cloud Bigtable service reports that the following "
"locations are temporarily unavailable and no information "
"about instances in these locations can be obtained:\n";
for (auto const& failed_location : instances->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 38 of file instance_admin.cc.

◆ project_id()

std::string const& google::cloud::bigtable::v0::InstanceAdmin::project_id ( ) const
inline

The project id, i.e., project_name() without the projects/ prefix.

Definition at line 170 of file instance_admin.h.

◆ project_name()

std::string const& google::cloud::bigtable::v0::InstanceAdmin::project_name ( ) const
inline

The full name (projects/<project_id>) of the project.

Definition at line 168 of file instance_admin.h.

◆ SetIamPolicy()

StatusOr< google::cloud::IamPolicy > google::cloud::bigtable::v0::InstanceAdmin::SetIamPolicy ( std::string const &  instance_id,
google::cloud::IamBindings const &  iam_bindings,
std::string const &  etag = std::string{} 
)

Sets the IAM policy for an instance.

Applications can provide the etag to implement optimistic concurrency control. If etag is not empty, the server will reject calls where the provided ETag does not match the ETag value stored in the server.

Parameters
instance_idwhich instance to set the IAM policy for.
iam_bindingsIamBindings object containing role and members.
etagthe expected ETag value for the current policy.
Returns
Policy the current IAM bindings for the instance.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string role, std::string member) {
StatusOr<google::cloud::IamPolicy> current =
instance_admin.GetIamPolicy(instance_id);
if (!current) {
throw std::runtime_error(current.status().message());
}
auto bindings = current->bindings;
bindings.AddMember(role, member);
StatusOr<google::cloud::IamPolicy> policy =
instance_admin.SetIamPolicy(instance_id, bindings, current->etag);
if (!policy) {
throw std::runtime_error(policy.status().message());
}
std::cout << "The IAM Policy for " << instance_id << " is\n";
for (auto const& kv : policy->bindings) {
std::cout << "role " << kv.first << " includes [";
char const* sep = "";
for (auto const& m : kv.second) {
std::cout << sep << m;
sep = ", ";
}
std::cout << "]\n";
}
}

Definition at line 787 of file instance_admin.cc.

◆ TestIamPermissions()

StatusOr< std::vector< std::string > > google::cloud::bigtable::v0::InstanceAdmin::TestIamPermissions ( std::string const &  instance_id,
std::vector< std::string > const &  permissions 
)

Returns a permission set that the caller has on the specified instance.

Parameters
instance_idthe ID of the instance to query.
permissionsset of permissions to check for the resource.
Idempotency
This operation is read-only and therefore it is always idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string resource,
std::vector<std::string> permissions) {
StatusOr<std::vector<std::string>> result =
instance_admin.TestIamPermissions(resource, permissions);
if (!result) {
throw std::runtime_error(result.status().message());
}
std::cout << "The current user has the following permissions [";
char const* sep = "";
for (auto const& p : *result) {
std::cout << sep << p;
sep = ", ";
}
std::cout << "]\n";
}
See also
https://cloud.google.com/bigtable/docs/access-control for a list of valid permissions on Google Cloud Bigtable.

Definition at line 863 of file instance_admin.cc.

◆ UpdateAppProfile()

future< StatusOr< btadmin::AppProfile > > google::cloud::bigtable::v0::InstanceAdmin::UpdateAppProfile ( std::string const &  instance_id,
std::string const &  profile_id,
AppProfileUpdateConfig  config 
)

Updates an existing application profile.

Parameters
instance_idthe instance for the new application profile.
profile_idthe id (not the full name) of the profile to update.
configthe configuration for the new application profile.
Returns
The proto describing the new application profile.
Idempotency
This operation is always treated as non-idempotent.
Change Description Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id, std::string description) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(
instance_id, profile_id,
cbt::AppProfileUpdateConfig().set_description(description));
auto profile = profile_future.get();
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}
Change Routing to Any Cluster Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(instance_id, profile_id,
cbt::AppProfileUpdateConfig()
.set_multi_cluster_use_any()
.set_ignore_warnings(true));
auto profile = profile_future.get();
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}
Change Routing to a Specific Cluster Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string profile_id, std::string cluster_id) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(
instance_id, profile_id,
cbt::AppProfileUpdateConfig()
.set_single_cluster_routing(cluster_id)
.set_ignore_warnings(true));
auto profile = profile_future.get();
if (!profile) {
throw std::runtime_error(profile.status().message());
}
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}

Definition at line 597 of file instance_admin.cc.

◆ UpdateCluster()

future< StatusOr< google::bigtable::admin::v2::Cluster > > google::cloud::bigtable::v0::InstanceAdmin::UpdateCluster ( ClusterConfig  cluster_config)

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.
Parameters
cluster_configcluster with updated values.
Returns
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.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id,
std::string cluster_id) {
// GetCluster first and then modify it.
StatusOr<google::bigtable::admin::v2::Cluster> cluster =
instance_admin.GetCluster(instance_id, cluster_id);
if (!cluster) {
throw std::runtime_error(cluster.status().message());
}
// The state cannot be sent on updates, so clear it first.
cluster->clear_state();
// Set the desired cluster configuration.
cluster->set_serve_nodes(4);
auto modified_config = cbt::ClusterConfig(std::move(*cluster));
StatusOr<google::bigtable::admin::v2::Cluster> modified_cluster =
instance_admin.UpdateCluster(modified_config).get();
if (!modified_cluster) {
throw std::runtime_error(modified_cluster.status().message());
}
std::cout << "cluster details : " << cluster->DebugString() << "\n";
}

Definition at line 475 of file instance_admin.cc.

◆ UpdateInstance()

future< StatusOr< google::bigtable::admin::v2::Instance > > google::cloud::bigtable::v0::InstanceAdmin::UpdateInstance ( InstanceUpdateConfig  instance_update_config)

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.
Parameters
instance_update_configconfig with modified instance.
Returns
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.
Idempotency
This operation is always treated as non-idempotent.
Example
using google::cloud::future;
using google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string instance_id) {
auto instance = instance_admin.GetInstance(instance_id);
if (!instance) {
throw std::runtime_error(instance.status().message());
}
// Modify the instance and prepare the mask with modified field
cbt::InstanceUpdateConfig instance_update_config(std::move(*instance));
instance_update_config.set_display_name("Modified Display Name");
future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
instance_admin.UpdateInstance(std::move(instance_update_config));
instance_future
.then([](future<StatusOr<google::bigtable::admin::v2::Instance>> f) {
auto updated_instance = f.get();
if (!updated_instance) {
throw std::runtime_error(updated_instance.status().message());
}
std::cout << "UpdateInstance details : "
<< updated_instance->DebugString() << "\n";
})
.get(); // block until done to simplify example
}

Definition at line 205 of file instance_admin.cc.