Class BigtableTableAdminClient (2.33.0)

public final class BigtableTableAdminClient implements AutoCloseable

Client for creating, configuring, and deleting Cloud Bigtable tables

Provides access to the table schemas only, not the data stored within the tables.

See the individual methods for example code.

Sample code to get started:


 // One instance per application.
 BigtableTableAdminClient client =  BigtableTableAdminClient.create("[PROJECT]", "[INSTANCE]");

 CreateTableRequest request =
   CreateTableRequest.of("my-table")
     .addFamily("cf1")
     .addFamily("cf2", GCRULES.maxVersions(10))
     .addSplit(ByteString.copyFromUtf8("b"))
     .addSplit(ByteString.copyFromUtf8("q"));
 client.createTable(request);

 // Cleanup during application shutdown.
 client.close();
 

Creating a new client is a very expensive operation and should only be done once and shared in an application. However, close() needs to be called on the client object to clean up resources such as threads during application shutdown.

This class can be customized by passing in a custom instance of BigtableTableAdminSettings to create(). For example:

To customize credentials:


 BigtableTableAdminSettings settings = BigtableTableAdminSettings.newBuilder()
   .setProjectId("[PROJECT]")
   .setInstanceId("[INSTANCE]")
   .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
   .build();

 BigtableTableAdminClient client = BigtableTableAdminClient.create(settings);
 

To customize the endpoint:


 BigtableTableAdminSettings.Builder settingsBuilder = BigtableTableAdminSettings.newBuilder()
   .setProjectId("[PROJECT]")
   .setInstanceId("[INSTANCE]");

 settingsBuilder.stubSettings()
   .setEndpoint(myEndpoint).build();

 BigtableTableAdminClient client = BigtableTableAdminClient.create(settingsBuilder.build());
 

Inheritance

java.lang.Object > BigtableTableAdminClient

Implements

AutoCloseable

Static Methods

create(BigtableTableAdminSettings settings)

public static BigtableTableAdminClient create(BigtableTableAdminSettings settings)

Constructs an instance of BigtableTableAdminClient with the given settings.

Parameter
NameDescription
settingsBigtableTableAdminSettings
Returns
TypeDescription
BigtableTableAdminClient
Exceptions
TypeDescription
IOException

create(String projectId, String instanceId)

public static BigtableTableAdminClient create(String projectId, String instanceId)

Constructs an instance of BigtableTableAdminClient with the given project and instance IDs.

Parameters
NameDescription
projectIdString
instanceIdString
Returns
TypeDescription
BigtableTableAdminClient
Exceptions
TypeDescription
IOException

create(String projectId, String instanceId, EnhancedBigtableTableAdminStub stub)

public static BigtableTableAdminClient create(String projectId, String instanceId, EnhancedBigtableTableAdminStub stub)

Constructs an instance of BigtableTableAdminClient with the given instance name and stub.

Parameters
NameDescription
projectIdString
instanceIdString
stubcom.google.cloud.bigtable.admin.v2.stub.EnhancedBigtableTableAdminStub
Returns
TypeDescription
BigtableTableAdminClient

Methods

awaitOptimizeRestoredTable(OptimizeRestoredTableOperationToken token)

public void awaitOptimizeRestoredTable(OptimizeRestoredTableOperationToken token)

Awaits a restored table is fully optimized.

Sample code


 RestoredTableResult result =
     client.restoreTable(RestoreTableRequest.of(clusterId, backupId).setTableId(tableId));
 client.awaitOptimizeRestoredTable(result.getOptimizeRestoredTableOperationToken());
 
Parameter
NameDescription
tokenOptimizeRestoredTableOperationToken
Exceptions
TypeDescription
ExecutionException
InterruptedException

awaitOptimizeRestoredTableAsync(OptimizeRestoredTableOperationToken token)

public ApiFuture<Void> awaitOptimizeRestoredTableAsync(OptimizeRestoredTableOperationToken token)

Awaits a restored table is fully optimized asynchronously.

Sample code


 RestoredTableResult result =
     client.restoreTable(RestoreTableRequest.of(clusterId, backupId).setTableId(tableId));
 ApiFuture<Void> future = client.awaitOptimizeRestoredTableAsync(
     result.getOptimizeRestoredTableOperationToken());

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Void unused) {
       System.out.println("The optimization of the restored table is done.");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
tokenOptimizeRestoredTableOperationToken
Returns
TypeDescription
ApiFuture<Void>

awaitReplication(String tableId)

public void awaitReplication(String tableId)

Blocks the current thread until replication has caught up to the point when this method was called. This allows callers to make sure that their mutations have been replicated across all of their clusters.

Sample code


 client.awaitReplication("my-table");
 
Parameter
NameDescription
tableIdString

awaitReplicationAsync(String tableId)

public ApiFuture<Void> awaitReplicationAsync(String tableId)

Returns a future that is resolved when replication has caught up to the point when this method was called. This allows callers to make sure that their mutations have been replicated across all of their clusters.

Sample code:


 ApiFuture<Void> replicationFuture = client.awaitReplicationAsync("my-table");

 ApiFutures.addCallback(
   replicationFuture,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Table table) {
       System.out.println("All clusters are now consistent");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );

 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Void>

close()

public void close()

copyBackup(CopyBackupRequest request)

public Backup copyBackup(CopyBackupRequest request)

Copy an existing backup to a new backup in a Cloud Bigtable cluster with the specified configuration.

Sample code Note: You want to create the client with project and instance where you want the new backup to be copied to.


 BigtableTableAdminClient client =  BigtableTableAdminClient.create("[PROJECT]", "[INSTANCE]");
 CopyBackupRequest request =
         CopyBackupRequest.of(sourceClusterId, sourceBackupId)
             .setDestination(clusterId, backupId)
             .setExpireTime(expireTime);
 Backup response = client.copyBackup(request);
 

If the source backup is located in a different instance


 CopyBackupRequest request =
         CopyBackupRequest.of(sourceClusterId, sourceBackupId)
             .setSourceInstance(sourceInstanceId)
             .setDestination(clusterId, backupId)
             .setExpireTime(expireTime);
 Backup response = client.copyBackup(request);
 

If the source backup is located in a different project


 CopyBackupRequest request =
         CopyBackupRequest.of(sourceClusterId, sourceBackupId)
             .setSourceInstance(sourceProjectId, sourceInstanceId)
             .setDestination(clusterId, backupId)
             .setExpireTime(expireTime);
 Backup response = client.copyBackup(request);
 
Parameter
NameDescription
requestCopyBackupRequest
Returns
TypeDescription
Backup

copyBackupAsync(CopyBackupRequest request)

public ApiFuture<Backup> copyBackupAsync(CopyBackupRequest request)

Creates a copy of a backup from an existing backup in a Cloud Bigtable cluster with the specified configuration asynchronously.

Sample code


 CopyBackupRequest request =
         CopyBackupRequest.of(sourceClusterId, sourceBackupId)
             .setDestination(clusterId, backupId)
             .setExpireTime(expireTime);
 ApiFuture<Backup> future = client.copyBackupAsync(request);

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Backup>() {
     public void onSuccess(Backup backup) {
       System.out.println("Successfully create the backup " + backup.getId());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
requestCopyBackupRequest
Returns
TypeDescription
ApiFuture<Backup>

createBackup(CreateBackupRequest request)

public Backup createBackup(CreateBackupRequest request)

Creates a backup with the specified configuration.

Sample code


 CreateBackupRequest request =
         CreateBackupRequest.of(clusterId, backupId)
             .setSourceTableId(tableId)
             .setExpireTime(expireTime);
 Backup response = client.createBackup(request);
 
Parameter
NameDescription
requestCreateBackupRequest
Returns
TypeDescription
Backup

createBackupAsync(CreateBackupRequest request)

public ApiFuture<Backup> createBackupAsync(CreateBackupRequest request)

Creates a backup with the specified configuration asynchronously.

Sample code


 CreateBackupRequest request =
         CreateBackupRequest.of(clusterId, backupId)
             .setSourceTableId(tableId)
             .setExpireTime(expireTime);
 ApiFuture<Backup> future = client.createBackupAsync(request);

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Backup>() {
     public void onSuccess(Backup backup) {
       System.out.println("Successfully create the backup " + backup.getId());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
requestCreateBackupRequest
Returns
TypeDescription
ApiFuture<Backup>

createTable(CreateTableRequest request)

public Table createTable(CreateTableRequest request)

Creates a new table with the specified configuration.

Sample code:


 // A table with a single column family, which retains only the latest value.
 Table table = client.createTable(
   CreateTableRequest.of("my-table")
     .addFamily("cf2", GCRULES.maxVersions(1))
 );

 // Another table with more complex garbage collection rules.
 Table table = client.createTable(
   CreateTableRequest.of("my-table")
     .addFamily("cf2", GCRULES.union()
       .rule(GCRULES.maxAge(Duration.ofDays(30)))
       .rule(GCRULES.maxVersions(5))
     )
 );
 

See Also: CreateTableRequestfor available options., GCRulesfor the documentation on available garbage collection rules.

Parameter
NameDescription
requestCreateTableRequest
Returns
TypeDescription
Table

createTableAsync(CreateTableRequest request)

public ApiFuture<Table> createTableAsync(CreateTableRequest request)

Asynchronously creates a new table with the specified configuration.

Sample code:


 // A table with a single column family, which retains values up to 7 days.
 ApiFuture<Table> tableFuture = client.createTableAsync(
   CreateTableRequest.of("my-table")
     .addFamily("cf", GCRULES.maxAge(Duration.ofDays(7)))
 );

 // Another table with more complex garbage collection rules.
 ApiFuture<Table> tableFuture = client.createTableAsync(
   CreateTableRequest.of("my-table")
     .addFamily("cf", GCRULES.intersection()
       .rule(GCRULES.maxAge(120, TimeUnit.HOURS))
       .rule(GCRULES.maxVersions(10))
     )
 );

 ApiFutures.addCallback(
   tableFuture,
   new ApiFutureCallback<Table>() {
     public void onSuccess(Table table) {
       System.out.println("Created table: " + table.getTableName());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 

See Also: CreateTableRequestfor available options., GCRulesfor the documentation on available garbage collection rules.

Parameter
NameDescription
requestCreateTableRequest
Returns
TypeDescription
ApiFuture<Table>

deleteBackup(String clusterId, String backupId)

public void deleteBackup(String clusterId, String backupId)

Deletes a backup with the specified backup ID in the specified cluster.

Sample code


 client.deleteBackup(clusterId, backupId);
 
Parameters
NameDescription
clusterIdString
backupIdString

deleteBackupAsync(String clusterId, String backupId)

public ApiFuture<Void> deleteBackupAsync(String clusterId, String backupId)

Deletes a backup with the specified backup ID in the specified cluster asynchronously.

Sample code


 ApiFuture<Void> future = client.deleteBackupAsync(clusterId, backupId);

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Backup>() {
     public void onSuccess(Void unused) {
       System.out.println("Successfully delete the backup.");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameters
NameDescription
clusterIdString
backupIdString
Returns
TypeDescription
ApiFuture<Void>

deleteTable(String tableId)

public void deleteTable(String tableId)

Deletes the table specified by the table ID.

Sample code:


 client.deleteTable("my-table");
 
Parameter
NameDescription
tableIdString

deleteTableAsync(String tableId)

public ApiFuture<Void> deleteTableAsync(String tableId)

Asynchronously deletes the table specified by the table ID.

Sample code:


 ApiFuture<Void> future = client.deleteTableAsync("my-table");

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Void ignored) {
       System.out.println("Successfully deleted the table");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Void>

dropAllRows(String tableId)

public void dropAllRows(String tableId)

Drops all data in the table.

Sample code:


 client.dropAllRows("my-table");
 
Parameter
NameDescription
tableIdString

dropAllRowsAsync(String tableId)

public ApiFuture<Void> dropAllRowsAsync(String tableId)

Asynchronously drops all data in the table.

Sample code:


 ApiFuture<Void> dropFuture = client.dropAllRowsAsync("my-table");

 ApiFutures.addCallback(
   dropFuture,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Void tableNames) {
       System.out.println("Successfully dropped all data");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Void>

dropRowRange(String tableId, ByteString rowKeyPrefix)

public void dropRowRange(String tableId, ByteString rowKeyPrefix)

Drops rows by the specified row key prefix and table ID.

Please note that this method is considered part of the admin API and is rate limited.

Sample code:


 client.dropRowRange("my-table", ByteString.copyFromUtf8("prefix"));
 
Parameters
NameDescription
tableIdString
rowKeyPrefixByteString

dropRowRange(String tableId, String rowKeyPrefix)

public void dropRowRange(String tableId, String rowKeyPrefix)

Drops rows by the specified row key prefix and table ID.

Please note that this method is considered part of the admin API and is rate limited.

Sample code:


 client.dropRowRange("my-table", "prefix");
 
Parameters
NameDescription
tableIdString
rowKeyPrefixString

dropRowRangeAsync(String tableId, ByteString rowKeyPrefix)

public ApiFuture<Void> dropRowRangeAsync(String tableId, ByteString rowKeyPrefix)

Asynchronously drops rows by the specified row key prefix and table ID.

Please note that this method is considered part of the admin API and is rate limited.

Sample code:


 ApiFuture<Void> dropFuture = client.dropRowRangeAsync("my-table", ByteString.copyFromUtf8("prefix"));

 ApiFutures.addCallback(
   dropFuture,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Void tableNames) {
       System.out.println("Successfully dropped row range.");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameters
NameDescription
tableIdString
rowKeyPrefixByteString
Returns
TypeDescription
ApiFuture<Void>

dropRowRangeAsync(String tableId, String rowKeyPrefix)

public ApiFuture<Void> dropRowRangeAsync(String tableId, String rowKeyPrefix)

Asynchronously drops rows by the specified row key prefix and table ID.

Please note that this method is considered part of the admin API and is rate limited.

Sample code:


 ApiFuture<Void> dropFuture = client.dropRowRangeAsync("my-table", "prefix");

 ApiFutures.addCallback(
   dropFuture,
   new ApiFutureCallback<Void>() {
     public void onSuccess(Void tableNames) {
       System.out.println("Successfully dropped row range.");
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameters
NameDescription
tableIdString
rowKeyPrefixString
Returns
TypeDescription
ApiFuture<Void>

exists(String tableId)

public boolean exists(String tableId)

Checks if the table specified by the table ID exists.

Sample code:


 if(client.exists("my-table")) {
   System.out.println("Table exists");
 }
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
boolean

existsAsync(String tableId)

public ApiFuture<Boolean> existsAsync(String tableId)

Asynchronously checks if the table specified by the table ID exists.

Sample code:


 ApiFuture<Boolean> found = client.existsAsync("my-table");

 ApiFutures.addCallback(
  found,
  new ApiFutureCallback<Boolean>() {
    public void onSuccess(Boolean found) {
      if (found) {
        System.out.println("Table exists");
      } else {
        System.out.println("Table not found");
      }
    }

    public void onFailure(Throwable t) {
      t.printStackTrace();
    }
  },
  MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Boolean>

getBackup(String clusterId, String backupId)

public Backup getBackup(String clusterId, String backupId)

Gets a backup with the specified backup ID in the specified cluster.

Sample code


 Backup backup = client.getBackup(clusterId, backupId);
 
Parameters
NameDescription
clusterIdString
backupIdString
Returns
TypeDescription
Backup

getBackupAsync(String clusterId, String backupId)

public ApiFuture<Backup> getBackupAsync(String clusterId, String backupId)

Gets a backup with the specified backup ID in the specified cluster asynchronously.

Sample code


 ApiFuture<Backup> future = client.getBackupAsync(clusterId, backupId);

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Backup>() {
     public void onSuccess(Backup backup) {
       System.out.println("Successfully get the backup " + backup.getId());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameters
NameDescription
clusterIdString
backupIdString
Returns
TypeDescription
ApiFuture<Backup>

getBackupIamPolicy(String clusterId, String backupId)

public Policy getBackupIamPolicy(String clusterId, String backupId)

Gets the IAM access control policy for the specified backup.

Sample code:


 Policy policy = client.getBackupIamPolicy("my-cluster-id", "my-backup-id");
 for(Map.Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
   System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
 }
 

See Also: Table-level IAM management

Parameters
NameDescription
clusterIdString
backupIdString
Returns
TypeDescription
com.google.cloud.Policy

getBackupIamPolicyAsync(String clusterId, String backupId)

public ApiFuture<Policy> getBackupIamPolicyAsync(String clusterId, String backupId)

Asynchronously gets the IAM access control policy for the specified backup.

Sample code:


 ApiFuture<Policy> policyFuture = client.getBackupIamPolicyAsync("my-cluster-id", "my-backup-id");

 ApiFutures.addCallback(policyFuture,
   new ApiFutureCallback<Policy>() {
     public void onSuccess(Policy policy) {
       for (Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
         System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Table-level IAM management

Parameters
NameDescription
clusterIdString
backupIdString
Returns
TypeDescription
ApiFuture<com.google.cloud.Policy>

getEncryptionInfo(String tableId)

public Map<String,List<EncryptionInfo>> getEncryptionInfo(String tableId)

Gets the current encryption info for the table across all of the clusters.

The returned Map will be keyed by cluster id and contain a status for all of the keys in use.

Parameter
NameDescription
tableIdString
Returns
TypeDescription
Map<String,List<EncryptionInfo>>

getEncryptionInfoAsync(String tableId)

public ApiFuture<Map<String,List<EncryptionInfo>>> getEncryptionInfoAsync(String tableId)

Asynchronously gets the current encryption info for the table across all of the clusters.

The returned Map will be keyed by cluster id and contain a status for all of the keys in use.

Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Map<String,List<EncryptionInfo>>>

getIamPolicy(String tableId)

public Policy getIamPolicy(String tableId)

Gets the IAM access control policy for the specified table.

Sample code:


 Policy policy = client.getIamPolicy("my-table");
 for(Map.Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
   System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
 }
 

See Also: Table-level IAM management

Parameter
NameDescription
tableIdString
Returns
TypeDescription
com.google.cloud.Policy

getIamPolicyAsync(String tableId)

public ApiFuture<Policy> getIamPolicyAsync(String tableId)

Asynchronously gets the IAM access control policy for the specified table.

Sample code:


 ApiFuture<Policy> policyFuture = client.getIamPolicyAsync("my-table");

 ApiFutures.addCallback(policyFuture,
   new ApiFutureCallback<Policy>() {
     public void onSuccess(Policy policy) {
       for (Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
         System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Table-level IAM management

Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<com.google.cloud.Policy>

getInstanceId()

public String getInstanceId()

Gets the ID of the instance whose tables this client manages.

Returns
TypeDescription
String

getProjectId()

public String getProjectId()

Gets the project ID of the instance whose tables this client manages.

Returns
TypeDescription
String

getTable(String tableId)

public Table getTable(String tableId)

Gets the table metadata by table ID.

Sample code:


 Table table = client.getTable("my-table");

 System.out.println("Got metadata for table: " + table.getId());
 System.out.println("Column families:");

 for (ColumnFamily cf : table.getColumnFamilies()) {
   System.out.println(cf.getId());
 }
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
Table

getTableAsync(String tableId)

public ApiFuture<Table> getTableAsync(String tableId)

Asynchronously gets the table metadata by table ID.

Sample code:


 ApiFuture<Table> tableFuture = client.getTableAsync("my-table");

 ApiFutures.addCallback(
   tableFuture,
   new ApiFutureCallback<Table>() {
     public void onSuccess(Table table) {
       System.out.println("Got metadata for table: " + table.getId());
       System.out.println("Column families:");
       for (ColumnFamily cf : table.getColumnFamilies()) {
         System.out.println(cf.getId());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
tableIdString
Returns
TypeDescription
ApiFuture<Table>

listBackups(String clusterId)

public List<String> listBackups(String clusterId)

Lists backups in the specified cluster.

Sample code


 List<String> backups = client.listBackups(clusterId);
 
Parameter
NameDescription
clusterIdString
Returns
TypeDescription
List<String>

listBackupsAsync(String clusterId)

public ApiFuture<List<String>> listBackupsAsync(String clusterId)

Lists backups in the specified cluster asynchronously.

Sample code:


 ApiFuture<List<String>> listFuture = client.listBackupsAsync(clusterId);

 ApiFutures.addCallback(
   listFuture,
   new ApiFutureCallback<List<String>>() {
     public void onSuccess(List<String> backupIds) {
       System.out.println("Got list of backups:");
       for (String backupId : backupIds) {
         System.out.println(backupId);
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
clusterIdString
Returns
TypeDescription
ApiFuture<List<String>>

listTables()

public List<String> listTables()

Lists all table IDs in the instance.

Sample code:


 List<String> tableIds = client.listTables();
 for(String tableId: tableIds) {
   System.out.println(name.getTable());
 }
 
Returns
TypeDescription
List<String>

listTablesAsync()

public ApiFuture<List<String>> listTablesAsync()

Asynchronously lists all table IDs in the instance.

Sample code:


 ApiFuture<List<String>> listFuture = client.listTables();

 ApiFutures.addCallback(
   listFuture,
   new ApiFutureCallback<List<String>>() {
     public void onSuccess(List<String> tableIds) {
       System.out.println("Got list of tables:");
       for (String tableId : tableIds) {
         System.out.println(tableId);
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Returns
TypeDescription
ApiFuture<List<String>>

modifyFamilies(ModifyColumnFamiliesRequest request)

public Table modifyFamilies(ModifyColumnFamiliesRequest request)

Creates, updates and drops column families as specified in the request.

Sample code:


 Table modifiedTable = client.modifyFamilies(
   ModifyColumnFamiliesRequest.of(tableId)
     .addFamily("cf1")
     .addFamily("cf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
     .updateFamily(
       "cf3",
       GCRULES.union()
         .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
         .rule(GCRULES.maxVersions(1))
       )
     .addFamily(
       "cf4",
       GCRULES.intersection()
         .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
         .rule(GCRULES.maxVersions(10))
     )
     .dropFamily("cf5")
 );

 System.out.println("Resulting families:");

 for (ColumnFamily cf : modifiedTable.getColumnFamilies()) {
   System.out.println(cf.getId());
 }
 

See Also: ModifyColumnFamiliesRequestfor available options.

Parameter
NameDescription
requestModifyColumnFamiliesRequest
Returns
TypeDescription
Table

modifyFamiliesAsync(ModifyColumnFamiliesRequest request)

public ApiFuture<Table> modifyFamiliesAsync(ModifyColumnFamiliesRequest request)

Asynchronously creates, updates, and drops column families as specified in the request.

Sample code:


 ApiFuture<Table> modifiedTableFuture = client.modifyFamiliesAsync(
   ModifyColumnFamiliesRequest.of(tableId)
     .addFamily("cf1")
     .addFamily("cf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
     .updateFamily(
       "cf3",
       GCRULES.union()
         .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
         .rule(GCRULES.maxVersions(1))
       )
     .addFamily(
       "cf4",
       GCRULES.intersection()
         .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
         .rule(GCRULES.maxVersions(10))
     )
     .dropFamily("cf5")
 );

 ApiFutures.addCallback(
   modifiedTableFuture,
   new ApiFutureCallback<Table>() {
     public void onSuccess(Table table) {
       System.out.println("Modified table: " + table.getTableName());
       System.out.println("Resulting families:");

       for (ColumnFamily cf : modifiedTable.getColumnFamilies()) {
         System.out.println(cf.getId());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 

See Also: ModifyColumnFamiliesRequestfor available options.

Parameter
NameDescription
requestModifyColumnFamiliesRequest
Returns
TypeDescription
ApiFuture<Table>

restoreTable(RestoreTableRequest request)

public RestoredTableResult restoreTable(RestoreTableRequest request)

Restores a backup to a new table with the specified configuration.

Sample code


 RestoredTableResult result =
     client.restoreTable(RestoreTableRequest.of(clusterId, backupId).setTableId(tableId));
 
Parameter
NameDescription
requestRestoreTableRequest
Returns
TypeDescription
RestoredTableResult
Exceptions
TypeDescription
ExecutionException
InterruptedException

restoreTableAsync(RestoreTableRequest request)

public ApiFuture<RestoredTableResult> restoreTableAsync(RestoreTableRequest request)

Restores a backup to a new table with the specified configuration asynchronously.

Sample code

{@code ApiFuture<RestoredTableResult> future = client.restoreTableAsync( RestoreTableRequest.of(clusterId, backupId).setTableId(tableId));

ApiFutures.addCallback( future, new ApiFutureCallback<RestoredTableResult>() { public void onSuccess(RestoredTableResult result) { System.out.println("Successfully restore the table."); }

 public void onFailure(Throwable t) {
   t.printStackTrace();
 }

}, MoreExecutors.directExecutor() );

Parameter
NameDescription
requestRestoreTableRequest
Returns
TypeDescription
ApiFuture<RestoredTableResult>

setBackupIamPolicy(String clusterId, String backupId, Policy policy)

public Policy setBackupIamPolicy(String clusterId, String backupId, Policy policy)

Replaces the IAM policy associated with the specified backup.

Sample code:


 Policy newPolicy = client.setBackupIamPolicy("my-cluster-id", "my-backup-id",
   Policy.newBuilder()
     .addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
     .addIdentity(Role.of("bigtable.admin"), Identity.group("admins@example.com"))
     .build());
 

See Also: Table-level IAM management

Parameters
NameDescription
clusterIdString
backupIdString
policycom.google.cloud.Policy
Returns
TypeDescription
com.google.cloud.Policy

setBackupIamPolicyAsync(String clusterId, String backupId, Policy policy)

public ApiFuture<Policy> setBackupIamPolicyAsync(String clusterId, String backupId, Policy policy)

Asynchronously replaces the IAM policy associated with the specified backup.

Sample code:


 ApiFuture<Policy> newPolicyFuture = client.setBackupIamPolicyAsync("my-cluster-id", "my-backup-id",
   Policy.newBuilder()
     .addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
     .addIdentity(Role.of("bigtable.admin"), Identity.group("admins@example.com"))
     .build());

 ApiFutures.addCallback(newPolicyFuture,
   new ApiFutureCallback<Policy>() {
     public void onSuccess(Policy policy) {
       for (Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
         System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Table-level IAM management

Parameters
NameDescription
clusterIdString
backupIdString
policycom.google.cloud.Policy
Returns
TypeDescription
ApiFuture<com.google.cloud.Policy>

setIamPolicy(String tableId, Policy policy)

public Policy setIamPolicy(String tableId, Policy policy)

Replaces the IAM policy associated with the specified table.

Sample code:


 Policy newPolicy = client.setIamPolicy("my-table",
   Policy.newBuilder()
     .addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
     .addIdentity(Role.of("bigtable.admin"), Identity.group("admins@example.com"))
     .build());
 

See Also: Table-level IAM management

Parameters
NameDescription
tableIdString
policycom.google.cloud.Policy
Returns
TypeDescription
com.google.cloud.Policy

setIamPolicyAsync(String tableId, Policy policy)

public ApiFuture<Policy> setIamPolicyAsync(String tableId, Policy policy)

Asynchronously replaces the IAM policy associated with the specified table.

Sample code:


 ApiFuture<Policy> newPolicyFuture = client.setIamPolicyAsync("my-table",
   Policy.newBuilder()
     .addIdentity(Role.of("bigtable.user"), Identity.user("someone@example.com"))
     .addIdentity(Role.of("bigtable.admin"), Identity.group("admins@example.com"))
     .build());

 ApiFutures.addCallback(policyFuture,
   new ApiFutureCallback<Policy>() {
     public void onSuccess(Policy policy) {
       for (Entry<Role, Set<Identity>> entry : policy.getBindings().entrySet()) {
         System.out.printf("Role: %s Identities: %s
", entry.getKey(), entry.getValue());
       }
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Table-level IAM management

Parameters
NameDescription
tableIdString
policycom.google.cloud.Policy
Returns
TypeDescription
ApiFuture<com.google.cloud.Policy>

testBackupIamPermission(String clusterId, String backupId, String[] permissions)

public List<String> testBackupIamPermission(String clusterId, String backupId, String[] permissions)

Tests whether the caller has the given permissions for the specified backup. Returns a subset of the specified permissions that the caller has.

Sample code:


 List<String> grantedPermissions = client.testBackupIamPermission("my-cluster-id", "my-backup-id",
   "bigtable.backups.restore", "bigtable.backups.delete");
 

System.out.println("Has restore access: " + grantedPermissions.contains("bigtable.backups.restore"));

System.out.println("Has delete access: " + grantedPermissions.contains("bigtable.backups.delete")); See Also: Cloud Bigtable permissions

Parameters
NameDescription
clusterIdString
backupIdString
permissionsString[]
Returns
TypeDescription
List<String>

testBackupIamPermissionAsync(String clusterId, String backupId, String[] permissions)

public ApiFuture<List<String>> testBackupIamPermissionAsync(String clusterId, String backupId, String[] permissions)

Asynchronously tests whether the caller has the given permissions for the specified backup. Returns a subset of the specified permissions that the caller has.

Sample code:


 ApiFuture<List<String>> grantedPermissionsFuture = client.testBackupIamPermissionAsync("my-cluster-id", "my-backup-id",
   "bigtable.backups.restore", "bigtable.backups.delete");

 ApiFutures.addCallback(grantedPermissionsFuture,
   new ApiFutureCallback<List<String>>() {
     public void onSuccess(List<String> grantedPermissions) {
       System.out.println("Has restore access: " + grantedPermissions.contains("bigtable.backups.restore"));
       System.out.println("Has delete access: " + grantedPermissions.contains("bigtable.backups.delete"));
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Cloud Bigtable permissions

Parameters
NameDescription
clusterIdString
backupIdString
permissionsString[]
Returns
TypeDescription
ApiFuture<List<String>>

testIamPermission(String tableId, String[] permissions)

public List<String> testIamPermission(String tableId, String[] permissions)

Tests whether the caller has the given permissions for the specified table. Returns a subset of the specified permissions that the caller has.

Sample code:


 List<String> grantedPermissions = client.testIamPermission("my-table",
   "bigtable.tables.readRows", "bigtable.tables.mutateRows");
 

System.out.println("Has read access: " + grantedPermissions.contains("bigtable.tables.readRows")); System.out.println("Has write access: " + grantedPermissions.contains("bigtable.tables.mutateRows")); See Also: Cloud Bigtable permissions

Parameters
NameDescription
tableIdString
permissionsString[]
Returns
TypeDescription
List<String>

testIamPermissionAsync(String tableId, String[] permissions)

public ApiFuture<List<String>> testIamPermissionAsync(String tableId, String[] permissions)

Asynchronously tests whether the caller has the given permissions for the specified table. Returns a subset of the specified permissions that the caller has.

Sample code:


 ApiFuture<List<String>> grantedPermissionsFuture = client.testIamPermissionAsync("my-table",
   "bigtable.tables.readRows", "bigtable.tables.mutateRows");

 ApiFutures.addCallback(grantedPermissionsFuture,
   new ApiFutureCallback<List<String>>() {
     public void onSuccess(List<String> grantedPermissions) {
       System.out.println("Has read access: " + grantedPermissions.contains("bigtable.tables.readRows"));
       System.out.println("Has write access: " + grantedPermissions.contains("bigtable.tables.mutateRows"));
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor());
 

See Also: Cloud Bigtable permissions

Parameters
NameDescription
tableIdString
permissionsString[]
Returns
TypeDescription
ApiFuture<List<String>>

updateBackup(UpdateBackupRequest request)

public Backup updateBackup(UpdateBackupRequest request)

Updates a backup with the specified configuration.

Sample code


 Backup backup = client.updateBackup(clusterId, backupId);
 
Parameter
NameDescription
requestUpdateBackupRequest
Returns
TypeDescription
Backup

updateBackupAsync(UpdateBackupRequest request)

public ApiFuture<Backup> updateBackupAsync(UpdateBackupRequest request)

Updates a backup with the specified configuration asynchronously.

Sample code


 ApiFuture<Backup> future = client.updateBackupAsync(clusterId, backupId);

 ApiFutures.addCallback(
   future,
   new ApiFutureCallback<Backup>() {
     public void onSuccess(Backup backup) {
       System.out.println("Successfully update the backup " + backup.getId());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 
Parameter
NameDescription
requestUpdateBackupRequest
Returns
TypeDescription
ApiFuture<Backup>

updateTable(UpdateTableRequest request)

public Table updateTable(UpdateTableRequest request)

Update a table with the specified configuration.

Sample code:


 // Alter change stream retention period.
 Table table = client.updateTable(
   UpdateTableRequest.of("my-table")
     .addChangeStreamRetention(Duration.ofHours(24))
 );

 // Disable change stream
 Table table = client.updateTable(
   UpdateTableRequest.of("my-table")
     .disableChangeStream()
 );
 

See Also: UpdateTableRequestfor available options.

Parameter
NameDescription
requestUpdateTableRequest
Returns
TypeDescription
Table

updateTableAsync(UpdateTableRequest request)

public ApiFuture<Table> updateTableAsync(UpdateTableRequest request)

Asynchronously update a table with the specified configuration.

Sample code:


 // Update table to 1 day change stream retention.
 ApiFuture<Table> tableFuture = client.createTableAsync(
   UpdateTableRequest.of("my-table")
     .addChangeStreamRetention(Duration.ofHours(24))
 );

 ApiFutures.addCallback(
   tableFuture,
   new ApiFutureCallback<Table>() {
     public void onSuccess(Table table) {
       System.out.println("Updated table: " + table.getTableName());
     }

     public void onFailure(Throwable t) {
       t.printStackTrace();
     }
   },
   MoreExecutors.directExecutor()
 );
 

See Also: UpdateTableRequestfor available options.

Parameter
NameDescription
requestUpdateTableRequest
Returns
TypeDescription
ApiFuture<Table>