@Generated(value="by GAPIC v0.0.5") @BetaApi public class BigtableTableAdminClient extends Object implements com.google.api.gax.core.BackgroundResource
Provides access to the table schemas only, not the data stored within the tables.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "";
Table table = Table.newBuilder().build();
Table response = bigtableTableAdminClient.createTable(parent, tableId, table);
}
Note: close() needs to be called on the bigtableTableAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of BigtableTableAdminSettings to create(). For example:
To customize credentials:
BigtableTableAdminSettings bigtableTableAdminSettings =
BigtableTableAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
BigtableTableAdminClient bigtableTableAdminClient =
BigtableTableAdminClient.create(bigtableTableAdminSettings);
To customize the endpoint:
BigtableTableAdminSettings bigtableTableAdminSettings =
BigtableTableAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
BigtableTableAdminClient bigtableTableAdminClient =
BigtableTableAdminClient.create(bigtableTableAdminSettings);
| Modifier | Constructor and Description |
|---|---|
protected |
BigtableTableAdminClient(BigtableTableAdminSettings settings)
Constructs an instance of BigtableTableAdminClient, using the given settings.
|
protected |
BigtableTableAdminClient(BigtableTableAdminStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static BigtableTableAdminClient |
create()
Constructs an instance of BigtableTableAdminClient with default settings.
|
static BigtableTableAdminClient |
create(BigtableTableAdminSettings settings)
Constructs an instance of BigtableTableAdminClient, using the given settings.
|
static BigtableTableAdminClient |
create(BigtableTableAdminStub stub)
Constructs an instance of BigtableTableAdminClient, using the given stub for making calls.
|
com.google.bigtable.admin.v2.Table |
createTable(com.google.bigtable.admin.v2.CreateTableRequest request)
Creates a new table in the specified instance.
|
com.google.bigtable.admin.v2.Table |
createTable(com.google.bigtable.admin.v2.InstanceName parent,
String tableId,
com.google.bigtable.admin.v2.Table table)
Creates a new table in the specified instance.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.CreateTableRequest,com.google.bigtable.admin.v2.Table> |
createTableCallable()
Creates a new table in the specified instance.
|
void |
deleteTable(com.google.bigtable.admin.v2.TableName name)
Permanently deletes a specified table and all of its data.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.DeleteTableRequest,com.google.protobuf.Empty> |
deleteTableCallable()
Permanently deletes a specified table and all of its data.
|
void |
dropRowRange(com.google.bigtable.admin.v2.DropRowRangeRequest request)
Permanently drop/delete a row range from a specified table.
|
void |
dropRowRange(String name,
com.google.protobuf.ByteString rowKeyPrefix)
Permanently drop/delete a row range from a specified table.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.DropRowRangeRequest,com.google.protobuf.Empty> |
dropRowRangeCallable()
Permanently drop/delete a row range from a specified table.
|
BigtableTableAdminSettings |
getSettings() |
BigtableTableAdminStub |
getStub() |
com.google.bigtable.admin.v2.Table |
getTable(com.google.bigtable.admin.v2.GetTableRequest request)
Gets metadata information about the specified table.
|
com.google.bigtable.admin.v2.Table |
getTable(com.google.bigtable.admin.v2.TableName name)
Gets metadata information about the specified table.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.GetTableRequest,com.google.bigtable.admin.v2.Table> |
getTableCallable()
Gets metadata information about the specified table.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
PagedResponseWrappers.ListTablesPagedResponse |
listTables(com.google.bigtable.admin.v2.InstanceName parent)
Lists all tables served from a specified instance.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ListTablesRequest,com.google.bigtable.admin.v2.ListTablesResponse> |
listTablesCallable()
Lists all tables served from a specified instance.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ListTablesRequest,PagedResponseWrappers.ListTablesPagedResponse> |
listTablesPagedCallable()
Lists all tables served from a specified instance.
|
com.google.bigtable.admin.v2.Table |
modifyColumnFamilies(com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest request)
Performs a series of column family modifications on the specified table.
|
com.google.bigtable.admin.v2.Table |
modifyColumnFamilies(com.google.bigtable.admin.v2.TableName name,
List<com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification> modifications)
Performs a series of column family modifications on the specified table.
|
com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest,com.google.bigtable.admin.v2.Table> |
modifyColumnFamiliesCallable()
Performs a series of column family modifications on the specified table.
|
void |
shutdown() |
void |
shutdownNow() |
protected BigtableTableAdminClient(BigtableTableAdminSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected BigtableTableAdminClient(BigtableTableAdminStub stub)
public static final BigtableTableAdminClient create() throws IOException
IOExceptionpublic static final BigtableTableAdminClient create(BigtableTableAdminSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final BigtableTableAdminClient create(BigtableTableAdminStub stub)
public final BigtableTableAdminSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public BigtableTableAdminStub getStub()
public final com.google.bigtable.admin.v2.Table createTable(com.google.bigtable.admin.v2.InstanceName parent,
String tableId,
com.google.bigtable.admin.v2.Table table)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "";
Table table = Table.newBuilder().build();
Table response = bigtableTableAdminClient.createTable(parent, tableId, table);
}
parent - The unique name of the instance in which to create the table. Values are of the
form `projects/<project>/instances/<instance>`.tableId - The name by which the new table should be referred to within the parent
instance, e.g., `foobar` rather than `<parent>/tables/foobar`.table - The Table to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.bigtable.admin.v2.Table createTable(com.google.bigtable.admin.v2.CreateTableRequest request)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "";
Table table = Table.newBuilder().build();
CreateTableRequest request = CreateTableRequest.newBuilder()
.setParentWithInstanceName(parent)
.setTableId(tableId)
.setTable(table)
.build();
Table response = bigtableTableAdminClient.createTable(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.CreateTableRequest,com.google.bigtable.admin.v2.Table> createTableCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "";
Table table = Table.newBuilder().build();
CreateTableRequest request = CreateTableRequest.newBuilder()
.setParentWithInstanceName(parent)
.setTableId(tableId)
.setTable(table)
.build();
ApiFuture<Table> future = bigtableTableAdminClient.createTableCallable().futureCall(request);
// Do something
Table response = future.get();
}
public final PagedResponseWrappers.ListTablesPagedResponse listTables(com.google.bigtable.admin.v2.InstanceName parent)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Table element : bigtableTableAdminClient.listTables(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - The unique name of the instance for which tables should be listed. Values are of
the form `projects/<project>/instances/<instance>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ListTablesRequest,PagedResponseWrappers.ListTablesPagedResponse> listTablesPagedCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListTablesRequest request = ListTablesRequest.newBuilder()
.setParentWithInstanceName(parent)
.build();
ApiFuture<ListTablesPagedResponse> future = bigtableTableAdminClient.listTablesPagedCallable().futureCall(request);
// Do something
for (Table element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ListTablesRequest,com.google.bigtable.admin.v2.ListTablesResponse> listTablesCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
ListTablesRequest request = ListTablesRequest.newBuilder()
.setParentWithInstanceName(parent)
.build();
while (true) {
ListTablesResponse response = bigtableTableAdminClient.listTablesCallable().call(request);
for (Table element : response.getTablesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.bigtable.admin.v2.Table getTable(com.google.bigtable.admin.v2.TableName name)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
Table response = bigtableTableAdminClient.getTable(name);
}
name - The unique name of the requested table. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.bigtable.admin.v2.Table getTable(com.google.bigtable.admin.v2.GetTableRequest request)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
GetTableRequest request = GetTableRequest.newBuilder()
.setNameWithTableName(name)
.build();
Table response = bigtableTableAdminClient.getTable(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.GetTableRequest,com.google.bigtable.admin.v2.Table> getTableCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
GetTableRequest request = GetTableRequest.newBuilder()
.setNameWithTableName(name)
.build();
ApiFuture<Table> future = bigtableTableAdminClient.getTableCallable().futureCall(request);
// Do something
Table response = future.get();
}
public final void deleteTable(com.google.bigtable.admin.v2.TableName name)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
bigtableTableAdminClient.deleteTable(name);
}
name - The unique name of the table to be deleted. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.DeleteTableRequest,com.google.protobuf.Empty> deleteTableCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
DeleteTableRequest request = DeleteTableRequest.newBuilder()
.setNameWithTableName(name)
.build();
ApiFuture<Void> future = bigtableTableAdminClient.deleteTableCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.bigtable.admin.v2.Table modifyColumnFamilies(com.google.bigtable.admin.v2.TableName name,
List<com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification> modifications)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
Table response = bigtableTableAdminClient.modifyColumnFamilies(name, modifications);
}
name - The unique name of the table whose families should be modified. Values are of the
form `projects/<project>/instances/<instance>/tables/<table>`.modifications - Modifications to be atomically applied to the specified table's families.
Entries are applied in order, meaning that earlier modifications can be masked by later
ones (in the case of repeated updates to the same family, for example).com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.bigtable.admin.v2.Table modifyColumnFamilies(com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest request)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
.setNameWithTableName(name)
.addAllModifications(modifications)
.build();
Table response = bigtableTableAdminClient.modifyColumnFamilies(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest,com.google.bigtable.admin.v2.Table> modifyColumnFamiliesCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
.setNameWithTableName(name)
.addAllModifications(modifications)
.build();
ApiFuture<Table> future = bigtableTableAdminClient.modifyColumnFamiliesCallable().futureCall(request);
// Do something
Table response = future.get();
}
public final void dropRowRange(String name, com.google.protobuf.ByteString rowKeyPrefix)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
String formattedName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString();
ByteString rowKeyPrefix = ByteString.copyFromUtf8("");
bigtableTableAdminClient.dropRowRange(formattedName, rowKeyPrefix);
}
name - The unique name of the table on which to drop a range of rows. Values are of the
form `projects/<project>/instances/<instance>/tables/<table>`.rowKeyPrefix - Delete all rows that start with this row key prefix. Prefix cannot be zero
length.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void dropRowRange(com.google.bigtable.admin.v2.DropRowRangeRequest request)
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
String formattedName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString();
DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
.setName(formattedName)
.build();
bigtableTableAdminClient.dropRowRange(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.bigtable.admin.v2.DropRowRangeRequest,com.google.protobuf.Empty> dropRowRangeCallable()
Sample code:
try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
String formattedName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString();
DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
.setName(formattedName)
.build();
ApiFuture<Void> future = bigtableTableAdminClient.dropRowRangeCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
throws Exception
close in interface AutoCloseableExceptionpublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2017 Google. All rights reserved.