Google Cloud Bigtable C++ Client  1.32.1
A C++ Client Library for Google Cloud Bigtable
Public Member Functions | List of all members
google::cloud::bigtable::v1::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...
 
std::string AppProfileName (std::string const &instance_id, std::string const &profile_id) const
 
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::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::Instance > > UpdateInstance (InstanceUpdateConfig instance_update_config)
 Update an existing instance of Cloud Bigtable. More...
 
StatusOr< InstanceListListInstances ()
 Obtain 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...
 
Status DeleteInstance (std::string const &instance_id)
 Deletes the instances in the project. 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< google::bigtable::admin::v2::Cluster > > UpdateCluster (ClusterConfig cluster_config)
 Update an existing cluster of Cloud Bigtable. More...
 
Status DeleteCluster (std::string const &instance_id, std::string const &cluster_id)
 Deletes the specified cluster of an instance in the project. 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...
 
StatusOr< google::bigtable::admin::v2::AppProfile > CreateAppProfile (std::string const &instance_id, AppProfileConfig config)
 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 > > UpdateAppProfile (std::string const &instance_id, std::string const &profile_id, AppProfileUpdateConfig config)
 Updates an existing application profile. More...
 
StatusOr< std::vector< google::bigtable::admin::v2::AppProfile > > ListAppProfiles (std::string const &instance_id)
 List the application 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...
 
StatusOr< google::cloud::IamPolicy > GetIamPolicy (std::string const &instance_id)
 Gets the policy for instance_id. More...
 
StatusOr< google::iam::v1::Policy > GetNativeIamPolicy (std::string const &instance_id)
 Gets the native 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...
 
StatusOr< google::iam::v1::Policy > SetIamPolicy (std::string const &instance_id, google::iam::v1::Policy const &iam_policy)
 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...
 

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 concurrently 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";
Implements the API to administer tables in a Cloud Bigtable instance.
Definition: table_admin.h:135
StatusOr<::google::bigtable::admin::v2::Table > GetTable(std::string const &table_id, TableView view=SCHEMA_VIEW)
Get information about a single table.
Definition: table_admin.cc:109
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.cc:23

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::v1::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 124 of file instance_admin.h.

Constructor & Destructor Documentation

◆ InstanceAdmin() [1/2]

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

Definition at line 129 of file instance_admin.h.

◆ InstanceAdmin() [2/2]

template<typename... Policies>
google::cloud::bigtable::v1::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 164 of file instance_admin.h.

Member Function Documentation

◆ AppProfileName()

std::string google::cloud::bigtable::v1::InstanceAdmin::AppProfileName ( std::string const &  instance_id,
std::string const &  profile_id 
) const
inline

Definition at line 188 of file instance_admin.h.

◆ ClusterName()

std::string google::cloud::bigtable::v1::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 182 of file instance_admin.h.

◆ CreateAppProfile()

StatusOr< btadmin::AppProfile > google::cloud::bigtable::v1::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.
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.
Multi-cluster Routing Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
Implements the APIs to administer Cloud Bigtable instances.
StatusOr< google::bigtable::admin::v2::AppProfile > CreateAppProfile(std::string const &instance_id, AppProfileConfig config)
Create a new application profile.
Single Cluster Routing Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& profile_id, std::string const& 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 337 of file instance_admin.cc.

◆ CreateCluster()

future< StatusOr< btadmin::Cluster > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& cluster_id, std::string const& 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";
}
Specify the initial configuration for a new cluster.
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.

Definition at line 118 of file instance_admin.cc.

◆ CreateInstance()

future< StatusOr< btadmin::Instance > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
future< StatusOr< google::bigtable::admin::v2::Instance > > CreateInstance(InstanceConfig instance_config)
Create a new instance of Cloud Bigtable.
Specify the initial configuration for a new instance.
InstanceConfig & set_type(InstanceType type)

Definition at line 87 of file instance_admin.cc.

◆ DeleteAppProfile()

Status google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
Status DeleteAppProfile(std::string const &instance_id, std::string const &profile_id, bool ignore_warnings=true)
Delete an existing application profile.

Definition at line 447 of file instance_admin.cc.

◆ DeleteCluster()

Status google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& cluster_id) {
google::cloud::Status status =
instance_admin.DeleteCluster(instance_id, cluster_id);
if (!status.ok()) throw std::runtime_error(status.message());
}
Status DeleteCluster(std::string const &instance_id, std::string const &cluster_id)
Deletes the specified cluster of an instance in the project.

Definition at line 319 of file instance_admin.cc.

◆ DeleteInstance()

Status google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
[](cbt::InstanceAdmin instance_admin, std::string const& 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";
}
Status DeleteInstance(std::string const &instance_id)
Deletes the instances in the project.

Definition at line 206 of file instance_admin.cc.

◆ GetAppProfile()

StatusOr< btadmin::AppProfile > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
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.

Definition at line 358 of file instance_admin.cc.

◆ GetCluster()

StatusOr< btadmin::Cluster > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
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.

Definition at line 221 of file instance_admin.cc.

◆ GetIamPolicy()

StatusOr< google::cloud::IamPolicy > google::cloud::bigtable::v1::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.
Deprecated:
this function is deprecated; it doesn't support conditional bindings and will not support any other features to come; please use GetNativeIamPolicy instead.
Idempotency
This operation is read-only and therefore it is always idempotent.
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.
Example
Use GetNativeIamPolicy() instead.

Definition at line 465 of file instance_admin.cc.

◆ GetInstance()

StatusOr< btadmin::Instance > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& 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";
}
StatusOr< google::bigtable::admin::v2::Instance > GetInstance(std::string const &instance_id)
Return the details of instance_id.

Definition at line 182 of file instance_admin.cc.

◆ GetNativeIamPolicy()

StatusOr< google::iam::v1::Policy > google::cloud::bigtable::v1::InstanceAdmin::GetNativeIamPolicy ( std::string const &  instance_id)

Gets the native policy for instance_id.

This is the preferred way to GetIamPolicy(). This is more closely coupled to the underlying protocol, enable more actions and is more likely to tolerate future protocol changes.

Parameters
instance_idthe instance to query.
Returns
google::iam::v1::Policy the full IAM policy for the instance.
Idempotency
This operation is read-only and therefore it is always idempotent.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id) {
StatusOr<google::iam::v1::Policy> policy =
instance_admin.GetNativeIamPolicy(instance_id);
if (!policy) throw std::runtime_error(policy.status().message());
std::cout << "The IAM Policy for " << instance_id << " is\n"
<< policy->DebugString() << "\n";
}
StatusOr< google::iam::v1::Policy > GetNativeIamPolicy(std::string const &instance_id)
Gets the native policy for instance_id.

Definition at line 490 of file instance_admin.cc.

◆ InstanceName()

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

Return the fully qualified name of the given instance_id.

Definition at line 176 of file instance_admin.h.

◆ ListAppProfiles()

StatusOr< std::vector< btadmin::AppProfile > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& 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";
}
}
StatusOr< std::vector< google::bigtable::admin::v2::AppProfile > > ListAppProfiles(std::string const &instance_id)
List the application profiles in an instance.

Definition at line 410 of file instance_admin.cc.

◆ ListClusters() [1/2]

StatusOr< ClusterList > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id) {
StatusOr<cbt::ClusterList> clusters =
instance_admin.ListClusters(instance_id);
if (!clusters) throw std::runtime_error(clusters.status().message());
std::cout << "Cluster Name List\n";
for (auto const& cluster : clusters->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!clusters->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 : clusters->failed_locations) {
std::cout << failed_location << "\n";
}
}
}
StatusOr< ClusterList > ListClusters()
Obtain the list of clusters in an instance.

Definition at line 242 of file instance_admin.cc.

◆ ListClusters() [2/2]

StatusOr< ClusterList > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id) {
StatusOr<cbt::ClusterList> clusters =
instance_admin.ListClusters(instance_id);
if (!clusters) throw std::runtime_error(clusters.status().message());
std::cout << "Cluster Name List\n";
for (auto const& cluster : clusters->clusters) {
std::cout << "Cluster Name:" << cluster.name() << "\n";
}
if (!clusters->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 : clusters->failed_locations) {
std::cout << failed_location << "\n";
}
}
}

Definition at line 246 of file instance_admin.cc.

◆ ListInstances()

StatusOr< InstanceList > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
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 43 of file instance_admin.cc.

◆ project_id()

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

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

Definition at line 173 of file instance_admin.h.

◆ project_name()

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

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

Definition at line 171 of file instance_admin.h.

◆ SetIamPolicy() [1/2]

StatusOr< google::cloud::IamPolicy > google::cloud::bigtable::v1::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.
Deprecated:
this function is deprecated; it doesn't support conditional bindings and will not support any other features to come; please use the overload for google::iam::v1::Policy instead.
Warning
ETags are currently not used by Cloud Bigtable.
Idempotency
This operation is always treated as non-idempotent.
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.
Example
Use SetIamPolicy(std::string const&, google::iam::v1::Policy const&) instead.

Definition at line 515 of file instance_admin.cc.

◆ SetIamPolicy() [2/2]

StatusOr< google::iam::v1::Policy > google::cloud::bigtable::v1::InstanceAdmin::SetIamPolicy ( std::string const &  instance_id,
google::iam::v1::Policy const &  iam_policy 
)

Sets the IAM policy for an instance.

This is the preferred way to the overload for IamBindings. This is more closely coupled to the underlying protocol, enable more actions and is more likely to tolerate future protocol changes.

Parameters
instance_idwhich instance to set the IAM policy for.
iam_policygoogle::iam::v1::Policy object containing role and members.
Returns
google::iam::v1::Policy the current IAM policy for the instance.
Warning
ETags are currently not used by Cloud Bigtable.
Idempotency
This operation is always treated as non-idempotent.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& role, std::string const& member) {
StatusOr<google::iam::v1::Policy> current =
instance_admin.GetNativeIamPolicy(instance_id);
if (!current) throw std::runtime_error(current.status().message());
// This example adds the member to all existing bindings for that role. If
// there are no such bindings, it adds a new one. This might not be what the
// user wants, e.g. in case of conditional bindings.
size_t num_added = 0;
for (auto& binding : *current->mutable_bindings()) {
if (binding.role() == role) {
binding.add_members(member);
++num_added;
}
}
if (num_added == 0) {
*current->add_bindings() = cbt::IamBinding(role, {member});
}
StatusOr<google::iam::v1::Policy> policy =
instance_admin.SetIamPolicy(instance_id, *current);
if (!policy) throw std::runtime_error(policy.status().message());
std::cout << "The IAM Policy for " << instance_id << " is\n"
<< policy->DebugString() << "\n";
}
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.
google::iam::v1::Binding IamBinding(std::string role, InputIt begin, InputIt end)
Create a google::iam::v1::Binding.
Definition: iam_binding.h:160

Definition at line 553 of file instance_admin.cc.

◆ TestIamPermissions()

StatusOr< std::vector< std::string > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& resource,
std::vector<std::string> const& 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 [";
std::cout << absl::StrJoin(*result, ", ");
std::cout << "]\n";
}
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.
See also
https://cloud.google.com/bigtable/docs/access-control for a list of valid permissions on Google Cloud Bigtable.

Definition at line 579 of file instance_admin.cc.

◆ UpdateAppProfile()

future< StatusOr< btadmin::AppProfile > > google::cloud::bigtable::v1::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.
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.
Change Description Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& profile_id, std::string const& description) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(
instance_id, profile_id,
auto profile = profile_future.get();
if (!profile) throw std::runtime_error(profile.status().message());
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}
Build a proto to update an Application Profile configuration.
AppProfileUpdateConfig & set_description(std::string description)
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.
Change Routing to Any Cluster Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& profile_id) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(instance_id, profile_id,
auto profile = profile_future.get();
if (!profile) throw std::runtime_error(profile.status().message());
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}
AppProfileUpdateConfig & set_ignore_warnings(bool value)
Change Routing to a Specific Cluster Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& profile_id, std::string const& cluster_id) {
future<StatusOr<google::bigtable::admin::v2::AppProfile>> profile_future =
instance_admin.UpdateAppProfile(
instance_id, profile_id,
auto profile = profile_future.get();
if (!profile) throw std::runtime_error(profile.status().message());
std::cout << "Updated AppProfile: " << profile->DebugString() << "\n";
}
AppProfileUpdateConfig & set_single_cluster_routing(std::string const &cluster_id, bool allow_transactional_writes=false)

Definition at line 377 of file instance_admin.cc.

◆ UpdateCluster()

future< StatusOr< google::bigtable::admin::v2::Cluster > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
std::string const& 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";
}
future< StatusOr< google::bigtable::admin::v2::Cluster > > UpdateCluster(ClusterConfig cluster_config)
Update an existing cluster of Cloud Bigtable.

Definition at line 293 of file instance_admin.cc.

◆ UpdateInstance()

future< StatusOr< google::bigtable::admin::v2::Instance > > google::cloud::bigtable::v1::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.
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.
Example
namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& 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
}
future< StatusOr< google::bigtable::admin::v2::Instance > > UpdateInstance(InstanceUpdateConfig instance_update_config)
Update an existing instance of Cloud Bigtable.
Specify the initial configuration for updating an instance.

Definition at line 155 of file instance_admin.cc.