diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java similarity index 79% rename from google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java rename to google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java index 5a67f6769b68..b0b9caefbc2a 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java @@ -84,14 +84,14 @@ * *
  * 
- * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+ * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
  *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
- *   Instance response = bigtableInstanceAdminClient.getInstance(name);
+ *   Instance response = baseBigtableInstanceAdminClient.getInstance(name);
  * }
  * 
  * 
* - *

Note: close() needs to be called on the bigtableInstanceAdminClient object to clean up + *

Note: close() needs to be called on the baseBigtableInstanceAdminClient object to clean up * resources such as threads. In the example above, try-with-resources is used, which automatically * calls close(). * @@ -115,19 +115,19 @@ * 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 BigtableInstanceAdminSettings - * to create(). For example: + *

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

To customize credentials: * *

  * 
- * BigtableInstanceAdminSettings bigtableInstanceAdminSettings =
- *     BigtableInstanceAdminSettings.newBuilder()
+ * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings =
+ *     BaseBigtableInstanceAdminSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * BigtableInstanceAdminClient bigtableInstanceAdminClient =
- *     BigtableInstanceAdminClient.create(bigtableInstanceAdminSettings);
+ * BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
+ *     BaseBigtableInstanceAdminClient.create(baseBigtableInstanceAdminSettings);
  * 
  * 
* @@ -135,62 +135,64 @@ * *
  * 
- * BigtableInstanceAdminSettings bigtableInstanceAdminSettings =
- *     BigtableInstanceAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * BigtableInstanceAdminClient bigtableInstanceAdminClient =
- *     BigtableInstanceAdminClient.create(bigtableInstanceAdminSettings);
+ * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings =
+ *     BaseBigtableInstanceAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
+ *     BaseBigtableInstanceAdminClient.create(baseBigtableInstanceAdminSettings);
  * 
  * 
*/ @Generated("by gapic-generator") @BetaApi -public class BigtableInstanceAdminClient implements BackgroundResource { - private final BigtableInstanceAdminSettings settings; +public class BaseBigtableInstanceAdminClient implements BackgroundResource { + private final BaseBigtableInstanceAdminSettings settings; private final BigtableInstanceAdminStub stub; private final OperationsClient operationsClient; - /** Constructs an instance of BigtableInstanceAdminClient with default settings. */ - public static final BigtableInstanceAdminClient create() throws IOException { - return create(BigtableInstanceAdminSettings.newBuilder().build()); + /** Constructs an instance of BaseBigtableInstanceAdminClient with default settings. */ + public static final BaseBigtableInstanceAdminClient create() throws IOException { + return create(BaseBigtableInstanceAdminSettings.newBuilder().build()); } /** - * Constructs an instance of BigtableInstanceAdminClient, using the given settings. The channels - * are created based on the settings passed in, or defaults for any settings that are not set. + * Constructs an instance of BaseBigtableInstanceAdminClient, using the given settings. The + * channels are created based on the settings passed in, or defaults for any settings that are not + * set. */ - public static final BigtableInstanceAdminClient create(BigtableInstanceAdminSettings settings) - throws IOException { - return new BigtableInstanceAdminClient(settings); + public static final BaseBigtableInstanceAdminClient create( + BaseBigtableInstanceAdminSettings settings) throws IOException { + return new BaseBigtableInstanceAdminClient(settings); } /** - * Constructs an instance of BigtableInstanceAdminClient, using the given stub for making calls. - * This is for advanced usage - prefer to use BigtableInstanceAdminSettings}. + * Constructs an instance of BaseBigtableInstanceAdminClient, using the given stub for making + * calls. This is for advanced usage - prefer to use BaseBigtableInstanceAdminSettings}. */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final BigtableInstanceAdminClient create(BigtableInstanceAdminStub stub) { - return new BigtableInstanceAdminClient(stub); + public static final BaseBigtableInstanceAdminClient create(BigtableInstanceAdminStub stub) { + return new BaseBigtableInstanceAdminClient(stub); } /** - * Constructs an instance of BigtableInstanceAdminClient, using the given settings. This is + * Constructs an instance of BaseBigtableInstanceAdminClient, using the given settings. This is * protected so that it is easy to make a subclass, but otherwise, the static factory methods * should be preferred. */ - protected BigtableInstanceAdminClient(BigtableInstanceAdminSettings settings) throws IOException { + protected BaseBigtableInstanceAdminClient(BaseBigtableInstanceAdminSettings settings) + throws IOException { this.settings = settings; this.stub = ((BigtableInstanceAdminStubSettings) settings.getStubSettings()).createStub(); this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); } @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected BigtableInstanceAdminClient(BigtableInstanceAdminStub stub) { + protected BaseBigtableInstanceAdminClient(BigtableInstanceAdminStub stub) { this.settings = null; this.stub = stub; this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); } - public final BigtableInstanceAdminSettings getSettings() { + public final BaseBigtableInstanceAdminSettings getSettings() { return settings; } @@ -216,12 +218,12 @@ public final OperationsClient getOperationsClient() { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   String instanceId = "";
    *   Instance instance = Instance.newBuilder().build();
    *   Map<String, Cluster> clusters = new HashMap<>();
-   *   Instance response = bigtableInstanceAdminClient.createInstanceAsync(parent, instanceId, instance, clusters).get();
+   *   Instance response = baseBigtableInstanceAdminClient.createInstanceAsync(parent, instanceId, instance, clusters).get();
    * }
    * 
* @@ -258,12 +260,12 @@ public final OperationFuture createInstanceAsy *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   String instanceId = "";
    *   Instance instance = Instance.newBuilder().build();
    *   Map<String, Cluster> clusters = new HashMap<>();
-   *   Instance response = bigtableInstanceAdminClient.createInstanceAsync(parent.toString(), instanceId, instance, clusters).get();
+   *   Instance response = baseBigtableInstanceAdminClient.createInstanceAsync(parent.toString(), instanceId, instance, clusters).get();
    * }
    * 
* @@ -300,7 +302,7 @@ public final OperationFuture createInstanceAsy *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   String instanceId = "";
    *   Instance instance = Instance.newBuilder().build();
@@ -311,7 +313,7 @@ public final OperationFuture createInstanceAsy
    *     .setInstance(instance)
    *     .putAllClusters(clusters)
    *     .build();
-   *   Instance response = bigtableInstanceAdminClient.createInstanceAsync(request).get();
+   *   Instance response = baseBigtableInstanceAdminClient.createInstanceAsync(request).get();
    * }
    * 
* @@ -332,7 +334,7 @@ public final OperationFuture createInstanceAsy *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   String instanceId = "";
    *   Instance instance = Instance.newBuilder().build();
@@ -343,7 +345,7 @@ public final OperationFuture createInstanceAsy
    *     .setInstance(instance)
    *     .putAllClusters(clusters)
    *     .build();
-   *   OperationFuture<Operation> future = bigtableInstanceAdminClient.createInstanceOperationCallable().futureCall(request);
+   *   OperationFuture<Operation> future = baseBigtableInstanceAdminClient.createInstanceOperationCallable().futureCall(request);
    *   // Do something
    *   Instance response = future.get();
    * }
@@ -362,7 +364,7 @@ public final OperationFuture createInstanceAsy
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   String instanceId = "";
    *   Instance instance = Instance.newBuilder().build();
@@ -373,7 +375,7 @@ public final OperationFuture createInstanceAsy
    *     .setInstance(instance)
    *     .putAllClusters(clusters)
    *     .build();
-   *   ApiFuture<Operation> future = bigtableInstanceAdminClient.createInstanceCallable().futureCall(request);
+   *   ApiFuture<Operation> future = baseBigtableInstanceAdminClient.createInstanceCallable().futureCall(request);
    *   // Do something
    *   Operation response = future.get();
    * }
@@ -390,9 +392,9 @@ public final UnaryCallable createInstanceCalla
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   Instance response = bigtableInstanceAdminClient.getInstance(name);
+   *   Instance response = baseBigtableInstanceAdminClient.getInstance(name);
    * }
    * 
* @@ -414,9 +416,9 @@ public final Instance getInstance(InstanceName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   Instance response = bigtableInstanceAdminClient.getInstance(name.toString());
+   *   Instance response = baseBigtableInstanceAdminClient.getInstance(name.toString());
    * }
    * 
* @@ -437,12 +439,12 @@ public final Instance getInstance(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   GetInstanceRequest request = GetInstanceRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   Instance response = bigtableInstanceAdminClient.getInstance(request);
+   *   Instance response = baseBigtableInstanceAdminClient.getInstance(request);
    * }
    * 
* @@ -460,12 +462,12 @@ private final Instance getInstance(GetInstanceRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   GetInstanceRequest request = GetInstanceRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<Instance> future = bigtableInstanceAdminClient.getInstanceCallable().futureCall(request);
+   *   ApiFuture<Instance> future = baseBigtableInstanceAdminClient.getInstanceCallable().futureCall(request);
    *   // Do something
    *   Instance response = future.get();
    * }
@@ -482,9 +484,9 @@ public final UnaryCallable getInstanceCallable() {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ListInstancesResponse response = bigtableInstanceAdminClient.listInstances(parent);
+   *   ListInstancesResponse response = baseBigtableInstanceAdminClient.listInstances(parent);
    * }
    * 
* @@ -508,9 +510,9 @@ public final ListInstancesResponse listInstances(ProjectName parent) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ListInstancesResponse response = bigtableInstanceAdminClient.listInstances(parent.toString());
+   *   ListInstancesResponse response = baseBigtableInstanceAdminClient.listInstances(parent.toString());
    * }
    * 
* @@ -531,12 +533,12 @@ public final ListInstancesResponse listInstances(String parent) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   ListInstancesRequest request = ListInstancesRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   ListInstancesResponse response = bigtableInstanceAdminClient.listInstances(request);
+   *   ListInstancesResponse response = baseBigtableInstanceAdminClient.listInstances(request);
    * }
    * 
* @@ -554,12 +556,12 @@ public final ListInstancesResponse listInstances(ListInstancesRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ProjectName parent = ProjectName.of("[PROJECT]");
    *   ListInstancesRequest request = ListInstancesRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   ApiFuture<ListInstancesResponse> future = bigtableInstanceAdminClient.listInstancesCallable().futureCall(request);
+   *   ApiFuture<ListInstancesResponse> future = baseBigtableInstanceAdminClient.listInstancesCallable().futureCall(request);
    *   // Do something
    *   ListInstancesResponse response = future.get();
    * }
@@ -576,10 +578,10 @@ public final UnaryCallable listInst
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   Instance instance = Instance.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Instance response = bigtableInstanceAdminClient.partialUpdateInstanceAsync(instance, updateMask).get();
+   *   Instance response = baseBigtableInstanceAdminClient.partialUpdateInstanceAsync(instance, updateMask).get();
    * }
    * 
* @@ -608,14 +610,14 @@ public final OperationFuture partialUpdateInst *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   Instance instance = Instance.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   PartialUpdateInstanceRequest request = PartialUpdateInstanceRequest.newBuilder()
    *     .setInstance(instance)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   Instance response = bigtableInstanceAdminClient.partialUpdateInstanceAsync(request).get();
+   *   Instance response = baseBigtableInstanceAdminClient.partialUpdateInstanceAsync(request).get();
    * }
    * 
* @@ -636,14 +638,14 @@ public final OperationFuture partialUpdateInst *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   Instance instance = Instance.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   PartialUpdateInstanceRequest request = PartialUpdateInstanceRequest.newBuilder()
    *     .setInstance(instance)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   OperationFuture<Operation> future = bigtableInstanceAdminClient.partialUpdateInstanceOperationCallable().futureCall(request);
+   *   OperationFuture<Operation> future = baseBigtableInstanceAdminClient.partialUpdateInstanceOperationCallable().futureCall(request);
    *   // Do something
    *   Instance response = future.get();
    * }
@@ -662,14 +664,14 @@ public final OperationFuture partialUpdateInst
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   Instance instance = Instance.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   PartialUpdateInstanceRequest request = PartialUpdateInstanceRequest.newBuilder()
    *     .setInstance(instance)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   ApiFuture<Operation> future = bigtableInstanceAdminClient.partialUpdateInstanceCallable().futureCall(request);
+   *   ApiFuture<Operation> future = baseBigtableInstanceAdminClient.partialUpdateInstanceCallable().futureCall(request);
    *   // Do something
    *   Operation response = future.get();
    * }
@@ -687,9 +689,9 @@ public final OperationFuture partialUpdateInst
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   bigtableInstanceAdminClient.deleteInstance(name);
+   *   baseBigtableInstanceAdminClient.deleteInstance(name);
    * }
    * 
* @@ -711,9 +713,9 @@ public final void deleteInstance(InstanceName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   bigtableInstanceAdminClient.deleteInstance(name.toString());
+   *   baseBigtableInstanceAdminClient.deleteInstance(name.toString());
    * }
    * 
* @@ -734,12 +736,12 @@ public final void deleteInstance(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   bigtableInstanceAdminClient.deleteInstance(request);
+   *   baseBigtableInstanceAdminClient.deleteInstance(request);
    * }
    * 
* @@ -757,12 +759,12 @@ private final void deleteInstance(DeleteInstanceRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<Void> future = bigtableInstanceAdminClient.deleteInstanceCallable().futureCall(request);
+   *   ApiFuture<Void> future = baseBigtableInstanceAdminClient.deleteInstanceCallable().futureCall(request);
    *   // Do something
    *   future.get();
    * }
@@ -779,11 +781,11 @@ public final UnaryCallable deleteInstanceCallable(
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String clusterId = "";
    *   Cluster cluster = Cluster.newBuilder().build();
-   *   Cluster response = bigtableInstanceAdminClient.createClusterAsync(parent, clusterId, cluster).get();
+   *   Cluster response = baseBigtableInstanceAdminClient.createClusterAsync(parent, clusterId, cluster).get();
    * }
    * 
* @@ -815,11 +817,11 @@ public final OperationFuture createClusterAsync( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String clusterId = "";
    *   Cluster cluster = Cluster.newBuilder().build();
-   *   Cluster response = bigtableInstanceAdminClient.createClusterAsync(parent.toString(), clusterId, cluster).get();
+   *   Cluster response = baseBigtableInstanceAdminClient.createClusterAsync(parent.toString(), clusterId, cluster).get();
    * }
    * 
* @@ -851,7 +853,7 @@ public final OperationFuture createClusterAsync( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String clusterId = "";
    *   Cluster cluster = Cluster.newBuilder().build();
@@ -860,7 +862,7 @@ public final OperationFuture createClusterAsync(
    *     .setClusterId(clusterId)
    *     .setCluster(cluster)
    *     .build();
-   *   Cluster response = bigtableInstanceAdminClient.createClusterAsync(request).get();
+   *   Cluster response = baseBigtableInstanceAdminClient.createClusterAsync(request).get();
    * }
    * 
* @@ -881,7 +883,7 @@ public final OperationFuture createClusterAsync( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String clusterId = "";
    *   Cluster cluster = Cluster.newBuilder().build();
@@ -890,7 +892,7 @@ public final OperationFuture createClusterAsync(
    *     .setClusterId(clusterId)
    *     .setCluster(cluster)
    *     .build();
-   *   OperationFuture<Operation> future = bigtableInstanceAdminClient.createClusterOperationCallable().futureCall(request);
+   *   OperationFuture<Operation> future = baseBigtableInstanceAdminClient.createClusterOperationCallable().futureCall(request);
    *   // Do something
    *   Cluster response = future.get();
    * }
@@ -909,7 +911,7 @@ public final OperationFuture createClusterAsync(
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String clusterId = "";
    *   Cluster cluster = Cluster.newBuilder().build();
@@ -918,7 +920,7 @@ public final OperationFuture createClusterAsync(
    *     .setClusterId(clusterId)
    *     .setCluster(cluster)
    *     .build();
-   *   ApiFuture<Operation> future = bigtableInstanceAdminClient.createClusterCallable().futureCall(request);
+   *   ApiFuture<Operation> future = baseBigtableInstanceAdminClient.createClusterCallable().futureCall(request);
    *   // Do something
    *   Operation response = future.get();
    * }
@@ -935,9 +937,9 @@ public final UnaryCallable createClusterCallabl
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   Cluster response = bigtableInstanceAdminClient.getCluster(name);
+   *   Cluster response = baseBigtableInstanceAdminClient.getCluster(name);
    * }
    * 
* @@ -959,9 +961,9 @@ public final Cluster getCluster(ClusterName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   Cluster response = bigtableInstanceAdminClient.getCluster(name.toString());
+   *   Cluster response = baseBigtableInstanceAdminClient.getCluster(name.toString());
    * }
    * 
* @@ -982,12 +984,12 @@ public final Cluster getCluster(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    *   GetClusterRequest request = GetClusterRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   Cluster response = bigtableInstanceAdminClient.getCluster(request);
+   *   Cluster response = baseBigtableInstanceAdminClient.getCluster(request);
    * }
    * 
* @@ -1005,12 +1007,12 @@ private final Cluster getCluster(GetClusterRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    *   GetClusterRequest request = GetClusterRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<Cluster> future = bigtableInstanceAdminClient.getClusterCallable().futureCall(request);
+   *   ApiFuture<Cluster> future = baseBigtableInstanceAdminClient.getClusterCallable().futureCall(request);
    *   // Do something
    *   Cluster response = future.get();
    * }
@@ -1027,9 +1029,9 @@ public final UnaryCallable getClusterCallable() {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListClustersResponse response = bigtableInstanceAdminClient.listClusters(parent);
+   *   ListClustersResponse response = baseBigtableInstanceAdminClient.listClusters(parent);
    * }
    * 
* @@ -1055,9 +1057,9 @@ public final ListClustersResponse listClusters(InstanceName parent) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListClustersResponse response = bigtableInstanceAdminClient.listClusters(parent.toString());
+   *   ListClustersResponse response = baseBigtableInstanceAdminClient.listClusters(parent.toString());
    * }
    * 
* @@ -1080,12 +1082,12 @@ public final ListClustersResponse listClusters(String parent) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   ListClustersRequest request = ListClustersRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   ListClustersResponse response = bigtableInstanceAdminClient.listClusters(request);
+   *   ListClustersResponse response = baseBigtableInstanceAdminClient.listClusters(request);
    * }
    * 
* @@ -1103,12 +1105,12 @@ public final ListClustersResponse listClusters(ListClustersRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   ListClustersRequest request = ListClustersRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   ApiFuture<ListClustersResponse> future = bigtableInstanceAdminClient.listClustersCallable().futureCall(request);
+   *   ApiFuture<ListClustersResponse> future = baseBigtableInstanceAdminClient.listClustersCallable().futureCall(request);
    *   // Do something
    *   ListClustersResponse response = future.get();
    * }
@@ -1125,16 +1127,14 @@ public final UnaryCallable listCluste
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
    *   int serveNodes = 0;
    *   Cluster request = Cluster.newBuilder()
    *     .setName(name.toString())
-   *     .setLocation(location.toString())
    *     .setServeNodes(serveNodes)
    *     .build();
-   *   Cluster response = bigtableInstanceAdminClient.updateClusterAsync(request).get();
+   *   Cluster response = baseBigtableInstanceAdminClient.updateClusterAsync(request).get();
    * }
    * 
* @@ -1154,16 +1154,14 @@ public final OperationFuture updateClusterAsync( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
    *   int serveNodes = 0;
    *   Cluster request = Cluster.newBuilder()
    *     .setName(name.toString())
-   *     .setLocation(location.toString())
    *     .setServeNodes(serveNodes)
    *     .build();
-   *   OperationFuture<Operation> future = bigtableInstanceAdminClient.updateClusterOperationCallable().futureCall(request);
+   *   OperationFuture<Operation> future = baseBigtableInstanceAdminClient.updateClusterOperationCallable().futureCall(request);
    *   // Do something
    *   Cluster response = future.get();
    * }
@@ -1182,16 +1180,14 @@ public final OperationFuture updateClusterAsync(
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
    *   int serveNodes = 0;
    *   Cluster request = Cluster.newBuilder()
    *     .setName(name.toString())
-   *     .setLocation(location.toString())
    *     .setServeNodes(serveNodes)
    *     .build();
-   *   ApiFuture<Operation> future = bigtableInstanceAdminClient.updateClusterCallable().futureCall(request);
+   *   ApiFuture<Operation> future = baseBigtableInstanceAdminClient.updateClusterCallable().futureCall(request);
    *   // Do something
    *   Operation response = future.get();
    * }
@@ -1208,9 +1204,9 @@ public final UnaryCallable updateClusterCallable() {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   bigtableInstanceAdminClient.deleteCluster(name);
+   *   baseBigtableInstanceAdminClient.deleteCluster(name);
    * }
    * 
* @@ -1232,9 +1228,9 @@ public final void deleteCluster(ClusterName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   bigtableInstanceAdminClient.deleteCluster(name.toString());
+   *   baseBigtableInstanceAdminClient.deleteCluster(name.toString());
    * }
    * 
* @@ -1255,12 +1251,12 @@ public final void deleteCluster(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    *   DeleteClusterRequest request = DeleteClusterRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   bigtableInstanceAdminClient.deleteCluster(request);
+   *   baseBigtableInstanceAdminClient.deleteCluster(request);
    * }
    * 
* @@ -1278,12 +1274,12 @@ private final void deleteCluster(DeleteClusterRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    *   DeleteClusterRequest request = DeleteClusterRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<Void> future = bigtableInstanceAdminClient.deleteClusterCallable().futureCall(request);
+   *   ApiFuture<Void> future = baseBigtableInstanceAdminClient.deleteClusterCallable().futureCall(request);
    *   // Do something
    *   future.get();
    * }
@@ -1300,11 +1296,11 @@ public final UnaryCallable deleteClusterCallable()
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String appProfileId = "";
    *   AppProfile appProfile = AppProfile.newBuilder().build();
-   *   AppProfile response = bigtableInstanceAdminClient.createAppProfile(parent, appProfileId, appProfile);
+   *   AppProfile response = baseBigtableInstanceAdminClient.createAppProfile(parent, appProfileId, appProfile);
    * }
    * 
* @@ -1335,11 +1331,11 @@ public final AppProfile createAppProfile( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String appProfileId = "";
    *   AppProfile appProfile = AppProfile.newBuilder().build();
-   *   AppProfile response = bigtableInstanceAdminClient.createAppProfile(parent.toString(), appProfileId, appProfile);
+   *   AppProfile response = baseBigtableInstanceAdminClient.createAppProfile(parent.toString(), appProfileId, appProfile);
    * }
    * 
* @@ -1370,7 +1366,7 @@ public final AppProfile createAppProfile( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String appProfileId = "";
    *   AppProfile appProfile = AppProfile.newBuilder().build();
@@ -1379,7 +1375,7 @@ public final AppProfile createAppProfile(
    *     .setAppProfileId(appProfileId)
    *     .setAppProfile(appProfile)
    *     .build();
-   *   AppProfile response = bigtableInstanceAdminClient.createAppProfile(request);
+   *   AppProfile response = baseBigtableInstanceAdminClient.createAppProfile(request);
    * }
    * 
* @@ -1397,7 +1393,7 @@ public final AppProfile createAppProfile(CreateAppProfileRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   String appProfileId = "";
    *   AppProfile appProfile = AppProfile.newBuilder().build();
@@ -1406,7 +1402,7 @@ public final AppProfile createAppProfile(CreateAppProfileRequest request) {
    *     .setAppProfileId(appProfileId)
    *     .setAppProfile(appProfile)
    *     .build();
-   *   ApiFuture<AppProfile> future = bigtableInstanceAdminClient.createAppProfileCallable().futureCall(request);
+   *   ApiFuture<AppProfile> future = baseBigtableInstanceAdminClient.createAppProfileCallable().futureCall(request);
    *   // Do something
    *   AppProfile response = future.get();
    * }
@@ -1423,9 +1419,9 @@ public final UnaryCallable createAppProfile
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
-   *   AppProfile response = bigtableInstanceAdminClient.getAppProfile(name);
+   *   AppProfile response = baseBigtableInstanceAdminClient.getAppProfile(name);
    * }
    * 
* @@ -1447,9 +1443,9 @@ public final AppProfile getAppProfile(AppProfileName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
-   *   AppProfile response = bigtableInstanceAdminClient.getAppProfile(name.toString());
+   *   AppProfile response = baseBigtableInstanceAdminClient.getAppProfile(name.toString());
    * }
    * 
* @@ -1470,12 +1466,12 @@ public final AppProfile getAppProfile(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    *   GetAppProfileRequest request = GetAppProfileRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   AppProfile response = bigtableInstanceAdminClient.getAppProfile(request);
+   *   AppProfile response = baseBigtableInstanceAdminClient.getAppProfile(request);
    * }
    * 
* @@ -1493,12 +1489,12 @@ private final AppProfile getAppProfile(GetAppProfileRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    *   GetAppProfileRequest request = GetAppProfileRequest.newBuilder()
    *     .setName(name.toString())
    *     .build();
-   *   ApiFuture<AppProfile> future = bigtableInstanceAdminClient.getAppProfileCallable().futureCall(request);
+   *   ApiFuture<AppProfile> future = baseBigtableInstanceAdminClient.getAppProfileCallable().futureCall(request);
    *   // Do something
    *   AppProfile response = future.get();
    * }
@@ -1515,9 +1511,9 @@ public final UnaryCallable getAppProfileCallab
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (AppProfile element : bigtableInstanceAdminClient.listAppProfiles(parent).iterateAll()) {
+   *   for (AppProfile element : baseBigtableInstanceAdminClient.listAppProfiles(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
@@ -1542,9 +1538,9 @@ public final ListAppProfilesPagedResponse listAppProfiles(InstanceName parent) {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (AppProfile element : bigtableInstanceAdminClient.listAppProfiles(parent.toString()).iterateAll()) {
+   *   for (AppProfile element : baseBigtableInstanceAdminClient.listAppProfiles(parent.toString()).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
@@ -1566,12 +1562,12 @@ public final ListAppProfilesPagedResponse listAppProfiles(String parent) {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   ListAppProfilesRequest request = ListAppProfilesRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   for (AppProfile element : bigtableInstanceAdminClient.listAppProfiles(request).iterateAll()) {
+   *   for (AppProfile element : baseBigtableInstanceAdminClient.listAppProfiles(request).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
@@ -1591,12 +1587,12 @@ public final ListAppProfilesPagedResponse listAppProfiles(ListAppProfilesRequest
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   ListAppProfilesRequest request = ListAppProfilesRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
-   *   ApiFuture<ListAppProfilesPagedResponse> future = bigtableInstanceAdminClient.listAppProfilesPagedCallable().futureCall(request);
+   *   ApiFuture<ListAppProfilesPagedResponse> future = baseBigtableInstanceAdminClient.listAppProfilesPagedCallable().futureCall(request);
    *   // Do something
    *   for (AppProfile element : future.get().iterateAll()) {
    *     // doThingsWith(element);
@@ -1616,13 +1612,13 @@ public final ListAppProfilesPagedResponse listAppProfiles(ListAppProfilesRequest
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    *   ListAppProfilesRequest request = ListAppProfilesRequest.newBuilder()
    *     .setParent(parent.toString())
    *     .build();
    *   while (true) {
-   *     ListAppProfilesResponse response = bigtableInstanceAdminClient.listAppProfilesCallable().call(request);
+   *     ListAppProfilesResponse response = baseBigtableInstanceAdminClient.listAppProfilesCallable().call(request);
    *     for (AppProfile element : response.getAppProfilesList()) {
    *       // doThingsWith(element);
    *     }
@@ -1648,10 +1644,10 @@ public final ListAppProfilesPagedResponse listAppProfiles(ListAppProfilesRequest
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfile appProfile = AppProfile.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   AppProfile response = bigtableInstanceAdminClient.updateAppProfileAsync(appProfile, updateMask).get();
+   *   AppProfile response = baseBigtableInstanceAdminClient.updateAppProfileAsync(appProfile, updateMask).get();
    * }
    * 
* @@ -1680,14 +1676,14 @@ public final OperationFuture updateAppProf *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfile appProfile = AppProfile.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   UpdateAppProfileRequest request = UpdateAppProfileRequest.newBuilder()
    *     .setAppProfile(appProfile)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   AppProfile response = bigtableInstanceAdminClient.updateAppProfileAsync(request).get();
+   *   AppProfile response = baseBigtableInstanceAdminClient.updateAppProfileAsync(request).get();
    * }
    * 
* @@ -1708,14 +1704,14 @@ public final OperationFuture updateAppProf *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfile appProfile = AppProfile.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   UpdateAppProfileRequest request = UpdateAppProfileRequest.newBuilder()
    *     .setAppProfile(appProfile)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   OperationFuture<Operation> future = bigtableInstanceAdminClient.updateAppProfileOperationCallable().futureCall(request);
+   *   OperationFuture<Operation> future = baseBigtableInstanceAdminClient.updateAppProfileOperationCallable().futureCall(request);
    *   // Do something
    *   AppProfile response = future.get();
    * }
@@ -1734,14 +1730,14 @@ public final OperationFuture updateAppProf
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfile appProfile = AppProfile.newBuilder().build();
    *   FieldMask updateMask = FieldMask.newBuilder().build();
    *   UpdateAppProfileRequest request = UpdateAppProfileRequest.newBuilder()
    *     .setAppProfile(appProfile)
    *     .setUpdateMask(updateMask)
    *     .build();
-   *   ApiFuture<Operation> future = bigtableInstanceAdminClient.updateAppProfileCallable().futureCall(request);
+   *   ApiFuture<Operation> future = baseBigtableInstanceAdminClient.updateAppProfileCallable().futureCall(request);
    *   // Do something
    *   Operation response = future.get();
    * }
@@ -1758,9 +1754,9 @@ public final UnaryCallable updateAppProfileC
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
-   *   bigtableInstanceAdminClient.deleteAppProfile(name);
+   *   baseBigtableInstanceAdminClient.deleteAppProfile(name);
    * }
    * 
* @@ -1782,9 +1778,9 @@ public final void deleteAppProfile(AppProfileName name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
-   *   bigtableInstanceAdminClient.deleteAppProfile(name.toString());
+   *   baseBigtableInstanceAdminClient.deleteAppProfile(name.toString());
    * }
    * 
* @@ -1805,14 +1801,14 @@ public final void deleteAppProfile(String name) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    *   boolean ignoreWarnings = false;
    *   DeleteAppProfileRequest request = DeleteAppProfileRequest.newBuilder()
    *     .setName(name.toString())
    *     .setIgnoreWarnings(ignoreWarnings)
    *     .build();
-   *   bigtableInstanceAdminClient.deleteAppProfile(request);
+   *   baseBigtableInstanceAdminClient.deleteAppProfile(request);
    * }
    * 
* @@ -1830,14 +1826,14 @@ public final void deleteAppProfile(DeleteAppProfileRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    *   boolean ignoreWarnings = false;
    *   DeleteAppProfileRequest request = DeleteAppProfileRequest.newBuilder()
    *     .setName(name.toString())
    *     .setIgnoreWarnings(ignoreWarnings)
    *     .build();
-   *   ApiFuture<Void> future = bigtableInstanceAdminClient.deleteAppProfileCallable().futureCall(request);
+   *   ApiFuture<Void> future = baseBigtableInstanceAdminClient.deleteAppProfileCallable().futureCall(request);
    *   // Do something
    *   future.get();
    * }
@@ -1855,9 +1851,9 @@ public final UnaryCallable deleteAppProfileCalla
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
-   *   Policy response = bigtableInstanceAdminClient.getIamPolicy(formattedResource);
+   *   Policy response = baseBigtableInstanceAdminClient.getIamPolicy(formattedResource);
    * }
    * 
* @@ -1880,12 +1876,12 @@ public final Policy getIamPolicy(String resource) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .build();
-   *   Policy response = bigtableInstanceAdminClient.getIamPolicy(request);
+   *   Policy response = baseBigtableInstanceAdminClient.getIamPolicy(request);
    * }
    * 
* @@ -1904,12 +1900,12 @@ private final Policy getIamPolicy(GetIamPolicyRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .build();
-   *   ApiFuture<Policy> future = bigtableInstanceAdminClient.getIamPolicyCallable().futureCall(request);
+   *   ApiFuture<Policy> future = baseBigtableInstanceAdminClient.getIamPolicyCallable().futureCall(request);
    *   // Do something
    *   Policy response = future.get();
    * }
@@ -1926,10 +1922,10 @@ public final UnaryCallable getIamPolicyCallable() {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = bigtableInstanceAdminClient.setIamPolicy(formattedResource, policy);
+   *   Policy response = baseBigtableInstanceAdminClient.setIamPolicy(formattedResource, policy);
    * }
    * 
* @@ -1955,14 +1951,14 @@ public final Policy setIamPolicy(String resource, Policy policy) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   Policy policy = Policy.newBuilder().build();
    *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .setPolicy(policy)
    *     .build();
-   *   Policy response = bigtableInstanceAdminClient.setIamPolicy(request);
+   *   Policy response = baseBigtableInstanceAdminClient.setIamPolicy(request);
    * }
    * 
* @@ -1980,14 +1976,14 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   Policy policy = Policy.newBuilder().build();
    *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .setPolicy(policy)
    *     .build();
-   *   ApiFuture<Policy> future = bigtableInstanceAdminClient.setIamPolicyCallable().futureCall(request);
+   *   ApiFuture<Policy> future = baseBigtableInstanceAdminClient.setIamPolicyCallable().futureCall(request);
    *   // Do something
    *   Policy response = future.get();
    * }
@@ -2004,10 +2000,10 @@ public final UnaryCallable setIamPolicyCallable() {
    * 

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = bigtableInstanceAdminClient.testIamPermissions(formattedResource, permissions);
+   *   TestIamPermissionsResponse response = baseBigtableInstanceAdminClient.testIamPermissions(formattedResource, permissions);
    * }
    * 
* @@ -2037,14 +2033,14 @@ public final TestIamPermissionsResponse testIamPermissions( *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   List<String> permissions = new ArrayList<>();
    *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .addAllPermissions(permissions)
    *     .build();
-   *   TestIamPermissionsResponse response = bigtableInstanceAdminClient.testIamPermissions(request);
+   *   TestIamPermissionsResponse response = baseBigtableInstanceAdminClient.testIamPermissions(request);
    * }
    * 
* @@ -2062,14 +2058,14 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq *

Sample code: * *


-   * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+   * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
    *   String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
    *   List<String> permissions = new ArrayList<>();
    *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
    *     .setResource(formattedResource)
    *     .addAllPermissions(permissions)
    *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = bigtableInstanceAdminClient.testIamPermissionsCallable().futureCall(request);
+   *   ApiFuture<TestIamPermissionsResponse> future = baseBigtableInstanceAdminClient.testIamPermissionsCallable().futureCall(request);
    *   // Do something
    *   TestIamPermissionsResponse response = future.get();
    * }
diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java
similarity index 94%
rename from google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
rename to google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java
index be3c9e201fc9..8069e05658b6 100644
--- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
+++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java
@@ -15,7 +15,7 @@
  */
 package com.google.cloud.bigtable.admin.v2;
 
-import static com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient.ListAppProfilesPagedResponse;
+import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse;
 
 import com.google.api.core.ApiFunction;
 import com.google.api.core.BetaApi;
@@ -68,7 +68,7 @@
 
 // AUTO-GENERATED DOCUMENTATION AND CLASS
 /**
- * Settings class to configure an instance of {@link BigtableInstanceAdminClient}.
+ * Settings class to configure an instance of {@link BaseBigtableInstanceAdminClient}.
  *
  * 

The default instance has everything set to sensible defaults: * @@ -84,17 +84,18 @@ * *

  * 
- * BigtableInstanceAdminSettings.Builder bigtableInstanceAdminSettingsBuilder =
- *     BigtableInstanceAdminSettings.newBuilder();
- * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
+ * BaseBigtableInstanceAdminSettings.Builder baseBigtableInstanceAdminSettingsBuilder =
+ *     BaseBigtableInstanceAdminSettings.newBuilder();
+ * baseBigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
  *     .setTotalTimeout(Duration.ofSeconds(30));
- * BigtableInstanceAdminSettings bigtableInstanceAdminSettings = bigtableInstanceAdminSettingsBuilder.build();
+ * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings = baseBigtableInstanceAdminSettingsBuilder.build();
  * 
  * 
*/ @Generated("by gapic-generator") @BetaApi -public class BigtableInstanceAdminSettings extends ClientSettings { +public class BaseBigtableInstanceAdminSettings + extends ClientSettings { /** Returns the object with the settings used for calls to createInstance. */ public UnaryCallSettings createInstanceSettings() { return ((BigtableInstanceAdminStubSettings) getStubSettings()).createInstanceSettings(); @@ -232,9 +233,9 @@ public UnaryCallSettings setIamPolicySettings() { return ((BigtableInstanceAdminStubSettings) getStubSettings()).testIamPermissionsSettings(); } - public static final BigtableInstanceAdminSettings create(BigtableInstanceAdminStubSettings stub) - throws IOException { - return new BigtableInstanceAdminSettings.Builder(stub.toBuilder()).build(); + public static final BaseBigtableInstanceAdminSettings create( + BigtableInstanceAdminStubSettings stub) throws IOException { + return new BaseBigtableInstanceAdminSettings.Builder(stub.toBuilder()).build(); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -286,13 +287,13 @@ public Builder toBuilder() { return new Builder(this); } - protected BigtableInstanceAdminSettings(Builder settingsBuilder) throws IOException { + protected BaseBigtableInstanceAdminSettings(Builder settingsBuilder) throws IOException { super(settingsBuilder); } - /** Builder for BigtableInstanceAdminSettings. */ + /** Builder for BaseBigtableInstanceAdminSettings. */ public static class Builder - extends ClientSettings.Builder { + extends ClientSettings.Builder { protected Builder() throws IOException { this((ClientContext) null); } @@ -305,7 +306,7 @@ private static Builder createDefault() { return new Builder(BigtableInstanceAdminStubSettings.newBuilder()); } - protected Builder(BigtableInstanceAdminSettings settings) { + protected Builder(BaseBigtableInstanceAdminSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -471,8 +472,8 @@ public UnaryCallSettings.Builder setIamPolicySettin } @Override - public BigtableInstanceAdminSettings build() throws IOException { - return new BigtableInstanceAdminSettings(this); + public BaseBigtableInstanceAdminSettings build() throws IOException { + return new BaseBigtableInstanceAdminSettings(this); } } } diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java new file mode 100644 index 000000000000..168d78d71cd3 --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java @@ -0,0 +1,1981 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.bigtable.admin.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.bigtable.admin.v2.CheckConsistencyRequest; +import com.google.bigtable.admin.v2.CheckConsistencyResponse; +import com.google.bigtable.admin.v2.ClusterName; +import com.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata; +import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; +import com.google.bigtable.admin.v2.CreateTableRequest; +import com.google.bigtable.admin.v2.DeleteSnapshotRequest; +import com.google.bigtable.admin.v2.DeleteTableRequest; +import com.google.bigtable.admin.v2.DropRowRangeRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; +import com.google.bigtable.admin.v2.GetSnapshotRequest; +import com.google.bigtable.admin.v2.GetTableRequest; +import com.google.bigtable.admin.v2.InstanceName; +import com.google.bigtable.admin.v2.ListSnapshotsRequest; +import com.google.bigtable.admin.v2.ListSnapshotsResponse; +import com.google.bigtable.admin.v2.ListTablesRequest; +import com.google.bigtable.admin.v2.ListTablesResponse; +import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; +import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification; +import com.google.bigtable.admin.v2.Snapshot; +import com.google.bigtable.admin.v2.SnapshotName; +import com.google.bigtable.admin.v2.SnapshotTableMetadata; +import com.google.bigtable.admin.v2.SnapshotTableRequest; +import com.google.bigtable.admin.v2.Table; +import com.google.bigtable.admin.v2.TableName; +import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; +import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStubSettings; +import com.google.longrunning.Operation; +import com.google.longrunning.OperationsClient; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. + * + *

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 (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+ *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+ *   String tableId = "";
+ *   Table table = Table.newBuilder().build();
+ *   Table response = baseBigtableTableAdminClient.createTable(parent, tableId, table);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the baseBigtableTableAdminClient 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: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

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 BaseBigtableTableAdminSettings + * to create(). For example: + * + *

To customize credentials: + * + *

+ * 
+ * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings =
+ *     BaseBigtableTableAdminSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * BaseBigtableTableAdminClient baseBigtableTableAdminClient =
+ *     BaseBigtableTableAdminClient.create(baseBigtableTableAdminSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings =
+ *     BaseBigtableTableAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * BaseBigtableTableAdminClient baseBigtableTableAdminClient =
+ *     BaseBigtableTableAdminClient.create(baseBigtableTableAdminSettings);
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class BaseBigtableTableAdminClient implements BackgroundResource { + private final BaseBigtableTableAdminSettings settings; + private final BigtableTableAdminStub stub; + private final OperationsClient operationsClient; + + /** Constructs an instance of BaseBigtableTableAdminClient with default settings. */ + public static final BaseBigtableTableAdminClient create() throws IOException { + return create(BaseBigtableTableAdminSettings.newBuilder().build()); + } + + /** + * Constructs an instance of BaseBigtableTableAdminClient, using the given settings. The channels + * are created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final BaseBigtableTableAdminClient create(BaseBigtableTableAdminSettings settings) + throws IOException { + return new BaseBigtableTableAdminClient(settings); + } + + /** + * Constructs an instance of BaseBigtableTableAdminClient, using the given stub for making calls. + * This is for advanced usage - prefer to use BaseBigtableTableAdminSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final BaseBigtableTableAdminClient create(BigtableTableAdminStub stub) { + return new BaseBigtableTableAdminClient(stub); + } + + /** + * Constructs an instance of BaseBigtableTableAdminClient, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected BaseBigtableTableAdminClient(BaseBigtableTableAdminSettings settings) + throws IOException { + this.settings = settings; + this.stub = ((BigtableTableAdminStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected BaseBigtableTableAdminClient(BigtableTableAdminStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final BaseBigtableTableAdminSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public BigtableTableAdminStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table in the specified instance. The table can be created with a full set of + * initial column families, specified in the request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   Table table = Table.newBuilder().build();
+   *   Table response = baseBigtableTableAdminClient.createTable(parent, tableId, table);
+   * }
+   * 
+ * + * @param parent The unique name of the instance in which to create the table. Values are of the + * form `projects/<project>/instances/<instance>`. + * @param tableId The name by which the new table should be referred to within the parent + * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. + * @param table The Table to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table createTable(InstanceName parent, String tableId, Table table) { + + CreateTableRequest request = + CreateTableRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setTableId(tableId) + .setTable(table) + .build(); + return createTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table in the specified instance. The table can be created with a full set of + * initial column families, specified in the request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   Table table = Table.newBuilder().build();
+   *   Table response = baseBigtableTableAdminClient.createTable(parent.toString(), tableId, table);
+   * }
+   * 
+ * + * @param parent The unique name of the instance in which to create the table. Values are of the + * form `projects/<project>/instances/<instance>`. + * @param tableId The name by which the new table should be referred to within the parent + * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. + * @param table The Table to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table createTable(String parent, String tableId, Table table) { + + CreateTableRequest request = + CreateTableRequest.newBuilder() + .setParent(parent) + .setTableId(tableId) + .setTable(table) + .build(); + return createTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table in the specified instance. The table can be created with a full set of + * initial column families, specified in the request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   Table table = Table.newBuilder().build();
+   *   CreateTableRequest request = CreateTableRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setTableId(tableId)
+   *     .setTable(table)
+   *     .build();
+   *   Table response = baseBigtableTableAdminClient.createTable(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table createTable(CreateTableRequest request) { + return createTableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table in the specified instance. The table can be created with a full set of + * initial column families, specified in the request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   Table table = Table.newBuilder().build();
+   *   CreateTableRequest request = CreateTableRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setTableId(tableId)
+   *     .setTable(table)
+   *     .build();
+   *   ApiFuture<Table> future = baseBigtableTableAdminClient.createTableCallable().futureCall(request);
+   *   // Do something
+   *   Table response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createTableCallable() { + return stub.createTableCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table from the specified snapshot. The target table must not exist. The snapshot + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   Table response = baseBigtableTableAdminClient.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
+   * }
+   * 
+ * + * @param parent The unique name of the instance in which to create the table. Values are of the + * form `projects/<project>/instances/<instance>`. + * @param tableId The name by which the new table should be referred to within the parent + * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. + * @param sourceSnapshot The unique name of the snapshot from which to restore the table. The + * snapshot and the table must be in the same instance. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createTableFromSnapshotAsync( + InstanceName parent, String tableId, SnapshotName sourceSnapshot) { + + CreateTableFromSnapshotRequest request = + CreateTableFromSnapshotRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setTableId(tableId) + .setSourceSnapshot(sourceSnapshot == null ? null : sourceSnapshot.toString()) + .build(); + return createTableFromSnapshotAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table from the specified snapshot. The target table must not exist. The snapshot + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   Table response = baseBigtableTableAdminClient.createTableFromSnapshotAsync(parent.toString(), tableId, sourceSnapshot.toString()).get();
+   * }
+   * 
+ * + * @param parent The unique name of the instance in which to create the table. Values are of the + * form `projects/<project>/instances/<instance>`. + * @param tableId The name by which the new table should be referred to within the parent + * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. + * @param sourceSnapshot The unique name of the snapshot from which to restore the table. The + * snapshot and the table must be in the same instance. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createTableFromSnapshotAsync( + String parent, String tableId, String sourceSnapshot) { + + CreateTableFromSnapshotRequest request = + CreateTableFromSnapshotRequest.newBuilder() + .setParent(parent) + .setTableId(tableId) + .setSourceSnapshot(sourceSnapshot) + .build(); + return createTableFromSnapshotAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table from the specified snapshot. The target table must not exist. The snapshot + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setTableId(tableId)
+   *     .setSourceSnapshot(sourceSnapshot.toString())
+   *     .build();
+   *   Table response = baseBigtableTableAdminClient.createTableFromSnapshotAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture createTableFromSnapshotAsync( + CreateTableFromSnapshotRequest request) { + return createTableFromSnapshotOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table from the specified snapshot. The target table must not exist. The snapshot + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setTableId(tableId)
+   *     .setSourceSnapshot(sourceSnapshot.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = baseBigtableTableAdminClient.createTableFromSnapshotOperationCallable().futureCall(request);
+   *   // Do something
+   *   Table response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable< + CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> + createTableFromSnapshotOperationCallable() { + return stub.createTableFromSnapshotOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new table from the specified snapshot. The target table must not exist. The snapshot + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   String tableId = "";
+   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setTableId(tableId)
+   *     .setSourceSnapshot(sourceSnapshot.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = baseBigtableTableAdminClient.createTableFromSnapshotCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + createTableFromSnapshotCallable() { + return stub.createTableFromSnapshotCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all tables served from a specified instance. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   for (Table element : baseBigtableTableAdminClient.listTables(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent The unique name of the instance for which tables should be listed. Values are of + * the form `projects/<project>/instances/<instance>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListTablesPagedResponse listTables(InstanceName parent) { + ListTablesRequest request = + ListTablesRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return listTables(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all tables served from a specified instance. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   for (Table element : baseBigtableTableAdminClient.listTables(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent The unique name of the instance for which tables should be listed. Values are of + * the form `projects/<project>/instances/<instance>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListTablesPagedResponse listTables(String parent) { + ListTablesRequest request = ListTablesRequest.newBuilder().setParent(parent).build(); + return listTables(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all tables served from a specified instance. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListTablesRequest request = ListTablesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Table element : baseBigtableTableAdminClient.listTables(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListTablesPagedResponse listTables(ListTablesRequest request) { + return listTablesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all tables served from a specified instance. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListTablesRequest request = ListTablesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListTablesPagedResponse> future = baseBigtableTableAdminClient.listTablesPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Table element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listTablesPagedCallable() { + return stub.listTablesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all tables served from a specified instance. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
+   *   ListTablesRequest request = ListTablesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListTablesResponse response = baseBigtableTableAdminClient.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 UnaryCallable listTablesCallable() { + return stub.listTablesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified table. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   Table response = baseBigtableTableAdminClient.getTable(name);
+   * }
+   * 
+ * + * @param name The unique name of the requested table. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table getTable(TableName name) { + + GetTableRequest request = + GetTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified table. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   Table response = baseBigtableTableAdminClient.getTable(name.toString());
+   * }
+   * 
+ * + * @param name The unique name of the requested table. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table getTable(String name) { + + GetTableRequest request = GetTableRequest.newBuilder().setName(name).build(); + return getTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified table. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GetTableRequest request = GetTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Table response = baseBigtableTableAdminClient.getTable(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table getTable(GetTableRequest request) { + return getTableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified table. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GetTableRequest request = GetTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Table> future = baseBigtableTableAdminClient.getTableCallable().futureCall(request);
+   *   // Do something
+   *   Table response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getTableCallable() { + return stub.getTableCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes a specified table and all of its data. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   baseBigtableTableAdminClient.deleteTable(name);
+   * }
+   * 
+ * + * @param name The unique name of the table to be deleted. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteTable(TableName name) { + + DeleteTableRequest request = + DeleteTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes a specified table and all of its data. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   baseBigtableTableAdminClient.deleteTable(name.toString());
+   * }
+   * 
+ * + * @param name The unique name of the table to be deleted. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteTable(String name) { + + DeleteTableRequest request = DeleteTableRequest.newBuilder().setName(name).build(); + deleteTable(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes a specified table and all of its data. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   DeleteTableRequest request = DeleteTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   baseBigtableTableAdminClient.deleteTable(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteTable(DeleteTableRequest request) { + deleteTableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes a specified table and all of its data. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   DeleteTableRequest request = DeleteTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = baseBigtableTableAdminClient.deleteTableCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteTableCallable() { + return stub.deleteTableCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Performs a series of column family modifications on the specified table. Either all or none of + * the modifications will occur before this method returns, but data requests received prior to + * that point may see a table where only some modifications have taken effect. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
+   *   Table response = baseBigtableTableAdminClient.modifyColumnFamilies(name, modifications);
+   * }
+   * 
+ * + * @param name The unique name of the table whose families should be modified. Values are of the + * form `projects/<project>/instances/<instance>/tables/<table>`. + * @param 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). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table modifyColumnFamilies( + TableName name, List modifications) { + + ModifyColumnFamiliesRequest request = + ModifyColumnFamiliesRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .addAllModifications(modifications) + .build(); + return modifyColumnFamilies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Performs a series of column family modifications on the specified table. Either all or none of + * the modifications will occur before this method returns, but data requests received prior to + * that point may see a table where only some modifications have taken effect. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
+   *   Table response = baseBigtableTableAdminClient.modifyColumnFamilies(name.toString(), modifications);
+   * }
+   * 
+ * + * @param name The unique name of the table whose families should be modified. Values are of the + * form `projects/<project>/instances/<instance>/tables/<table>`. + * @param 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). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table modifyColumnFamilies( + String name, List modifications) { + + ModifyColumnFamiliesRequest request = + ModifyColumnFamiliesRequest.newBuilder() + .setName(name) + .addAllModifications(modifications) + .build(); + return modifyColumnFamilies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Performs a series of column family modifications on the specified table. Either all or none of + * the modifications will occur before this method returns, but data requests received prior to + * that point may see a table where only some modifications have taken effect. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
+   *   ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .addAllModifications(modifications)
+   *     .build();
+   *   Table response = baseBigtableTableAdminClient.modifyColumnFamilies(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Table modifyColumnFamilies(ModifyColumnFamiliesRequest request) { + return modifyColumnFamiliesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Performs a series of column family modifications on the specified table. Either all or none of + * the modifications will occur before this method returns, but data requests received prior to + * that point may see a table where only some modifications have taken effect. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
+   *   ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .addAllModifications(modifications)
+   *     .build();
+   *   ApiFuture<Table> future = baseBigtableTableAdminClient.modifyColumnFamiliesCallable().futureCall(request);
+   *   // Do something
+   *   Table response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable modifyColumnFamiliesCallable() { + return stub.modifyColumnFamiliesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently drop/delete a row range from a specified table. The request can specify whether to + * delete all rows in a table, or only those that match a particular prefix. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   baseBigtableTableAdminClient.dropRowRange(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void dropRowRange(DropRowRangeRequest request) { + dropRowRangeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently drop/delete a row range from a specified table. The request can specify whether to + * delete all rows in a table, or only those that match a particular prefix. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = baseBigtableTableAdminClient.dropRowRangeCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable dropRowRangeCallable() { + return stub.dropRowRangeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Generates a consistency token for a Table, which can be used in CheckConsistency to check + * whether mutations to the table that finished before this call started have been replicated. The + * tokens will be available for 90 days. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GenerateConsistencyTokenResponse response = baseBigtableTableAdminClient.generateConsistencyToken(name);
+   * }
+   * 
+ * + * @param name The unique name of the Table for which to create a consistency token. Values are of + * the form `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final GenerateConsistencyTokenResponse generateConsistencyToken(TableName name) { + + GenerateConsistencyTokenRequest request = + GenerateConsistencyTokenRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return generateConsistencyToken(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Generates a consistency token for a Table, which can be used in CheckConsistency to check + * whether mutations to the table that finished before this call started have been replicated. The + * tokens will be available for 90 days. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GenerateConsistencyTokenResponse response = baseBigtableTableAdminClient.generateConsistencyToken(name.toString());
+   * }
+   * 
+ * + * @param name The unique name of the Table for which to create a consistency token. Values are of + * the form `projects/<project>/instances/<instance>/tables/<table>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final GenerateConsistencyTokenResponse generateConsistencyToken(String name) { + + GenerateConsistencyTokenRequest request = + GenerateConsistencyTokenRequest.newBuilder().setName(name).build(); + return generateConsistencyToken(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Generates a consistency token for a Table, which can be used in CheckConsistency to check + * whether mutations to the table that finished before this call started have been replicated. The + * tokens will be available for 90 days. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   GenerateConsistencyTokenResponse response = baseBigtableTableAdminClient.generateConsistencyToken(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final GenerateConsistencyTokenResponse generateConsistencyToken( + GenerateConsistencyTokenRequest request) { + return generateConsistencyTokenCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Generates a consistency token for a Table, which can be used in CheckConsistency to check + * whether mutations to the table that finished before this call started have been replicated. The + * tokens will be available for 90 days. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<GenerateConsistencyTokenResponse> future = baseBigtableTableAdminClient.generateConsistencyTokenCallable().futureCall(request);
+   *   // Do something
+   *   GenerateConsistencyTokenResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + generateConsistencyTokenCallable() { + return stub.generateConsistencyTokenCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Checks replication consistency based on a consistency token, that is, if replication has caught + * up based on the conditions specified in the token and the check request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   String consistencyToken = "";
+   *   CheckConsistencyResponse response = baseBigtableTableAdminClient.checkConsistency(name, consistencyToken);
+   * }
+   * 
+ * + * @param name The unique name of the Table for which to check replication consistency. Values are + * of the form `projects/<project>/instances/<instance>/tables/<table>`. + * @param consistencyToken The token created using GenerateConsistencyToken for the Table. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CheckConsistencyResponse checkConsistency(TableName name, String consistencyToken) { + + CheckConsistencyRequest request = + CheckConsistencyRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setConsistencyToken(consistencyToken) + .build(); + return checkConsistency(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Checks replication consistency based on a consistency token, that is, if replication has caught + * up based on the conditions specified in the token and the check request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   String consistencyToken = "";
+   *   CheckConsistencyResponse response = baseBigtableTableAdminClient.checkConsistency(name.toString(), consistencyToken);
+   * }
+   * 
+ * + * @param name The unique name of the Table for which to check replication consistency. Values are + * of the form `projects/<project>/instances/<instance>/tables/<table>`. + * @param consistencyToken The token created using GenerateConsistencyToken for the Table. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CheckConsistencyResponse checkConsistency(String name, String consistencyToken) { + + CheckConsistencyRequest request = + CheckConsistencyRequest.newBuilder() + .setName(name) + .setConsistencyToken(consistencyToken) + .build(); + return checkConsistency(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Checks replication consistency based on a consistency token, that is, if replication has caught + * up based on the conditions specified in the token and the check request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   String consistencyToken = "";
+   *   CheckConsistencyRequest request = CheckConsistencyRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setConsistencyToken(consistencyToken)
+   *     .build();
+   *   CheckConsistencyResponse response = baseBigtableTableAdminClient.checkConsistency(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CheckConsistencyResponse checkConsistency(CheckConsistencyRequest request) { + return checkConsistencyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Checks replication consistency based on a consistency token, that is, if replication has caught + * up based on the conditions specified in the token and the check request. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   String consistencyToken = "";
+   *   CheckConsistencyRequest request = CheckConsistencyRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setConsistencyToken(consistencyToken)
+   *     .build();
+   *   ApiFuture<CheckConsistencyResponse> future = baseBigtableTableAdminClient.checkConsistencyCallable().futureCall(request);
+   *   // Do something
+   *   CheckConsistencyResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + checkConsistencyCallable() { + return stub.checkConsistencyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new snapshot in the specified cluster from the specified source table. The cluster + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   String description = "";
+   *   Snapshot response = baseBigtableTableAdminClient.snapshotTableAsync(name, cluster, snapshotId, description).get();
+   * }
+   * 
+ * + * @param name The unique name of the table to have the snapshot taken. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @param cluster The name of the cluster where the snapshot will be created in. Values are of the + * form `projects/<project>/instances/<instance>/clusters/<cluster>`. + * @param snapshotId The ID by which the new snapshot should be referred to within the parent + * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`. + * @param description Description of the snapshot. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture snapshotTableAsync( + TableName name, ClusterName cluster, SnapshotName snapshotId, String description) { + + SnapshotTableRequest request = + SnapshotTableRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setCluster(cluster == null ? null : cluster.toString()) + .setSnapshotId(snapshotId == null ? null : snapshotId.toString()) + .setDescription(description) + .build(); + return snapshotTableAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new snapshot in the specified cluster from the specified source table. The cluster + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   String description = "";
+   *   Snapshot response = baseBigtableTableAdminClient.snapshotTableAsync(name.toString(), cluster.toString(), snapshotId.toString(), description).get();
+   * }
+   * 
+ * + * @param name The unique name of the table to have the snapshot taken. Values are of the form + * `projects/<project>/instances/<instance>/tables/<table>`. + * @param cluster The name of the cluster where the snapshot will be created in. Values are of the + * form `projects/<project>/instances/<instance>/clusters/<cluster>`. + * @param snapshotId The ID by which the new snapshot should be referred to within the parent + * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`. + * @param description Description of the snapshot. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture snapshotTableAsync( + String name, String cluster, String snapshotId, String description) { + + SnapshotTableRequest request = + SnapshotTableRequest.newBuilder() + .setName(name) + .setCluster(cluster) + .setSnapshotId(snapshotId) + .setDescription(description) + .build(); + return snapshotTableAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new snapshot in the specified cluster from the specified source table. The cluster + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   String description = "";
+   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setCluster(cluster.toString())
+   *     .setSnapshotId(snapshotId.toString())
+   *     .setDescription(description)
+   *     .build();
+   *   Snapshot response = baseBigtableTableAdminClient.snapshotTableAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture snapshotTableAsync( + SnapshotTableRequest request) { + return snapshotTableOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new snapshot in the specified cluster from the specified source table. The cluster + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   String description = "";
+   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setCluster(cluster.toString())
+   *     .setSnapshotId(snapshotId.toString())
+   *     .setDescription(description)
+   *     .build();
+   *   OperationFuture<Operation> future = baseBigtableTableAdminClient.snapshotTableOperationCallable().futureCall(request);
+   *   // Do something
+   *   Snapshot response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable + snapshotTableOperationCallable() { + return stub.snapshotTableOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new snapshot in the specified cluster from the specified source table. The cluster + * and the table must be in the same instance. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   String description = "";
+   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setCluster(cluster.toString())
+   *     .setSnapshotId(snapshotId.toString())
+   *     .setDescription(description)
+   *     .build();
+   *   ApiFuture<Operation> future = baseBigtableTableAdminClient.snapshotTableCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable snapshotTableCallable() { + return stub.snapshotTableCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   Snapshot response = baseBigtableTableAdminClient.getSnapshot(name);
+   * }
+   * 
+ * + * @param name The unique name of the requested snapshot. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Snapshot getSnapshot(SnapshotName name) { + + GetSnapshotRequest request = + GetSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getSnapshot(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   Snapshot response = baseBigtableTableAdminClient.getSnapshot(name.toString());
+   * }
+   * 
+ * + * @param name The unique name of the requested snapshot. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Snapshot getSnapshot(String name) { + + GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setName(name).build(); + return getSnapshot(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   GetSnapshotRequest request = GetSnapshotRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Snapshot response = baseBigtableTableAdminClient.getSnapshot(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final Snapshot getSnapshot(GetSnapshotRequest request) { + return getSnapshotCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets metadata information about the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   GetSnapshotRequest request = GetSnapshotRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Snapshot> future = baseBigtableTableAdminClient.getSnapshotCallable().futureCall(request);
+   *   // Do something
+   *   Snapshot response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getSnapshotCallable() { + return stub.getSnapshotCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all snapshots associated with the specified cluster. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   for (Snapshot element : baseBigtableTableAdminClient.listSnapshots(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent The unique name of the cluster for which snapshots should be listed. Values are + * of the form `projects/<project>/instances/<instance>/clusters/<cluster>`. + * Use `<cluster> = '-'` to list snapshots for all clusters in an instance, e.g., + * `projects/<project>/instances/<instance>/clusters/-`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSnapshotsPagedResponse listSnapshots(ClusterName parent) { + ListSnapshotsRequest request = + ListSnapshotsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listSnapshots(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all snapshots associated with the specified cluster. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   for (Snapshot element : baseBigtableTableAdminClient.listSnapshots(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent The unique name of the cluster for which snapshots should be listed. Values are + * of the form `projects/<project>/instances/<instance>/clusters/<cluster>`. + * Use `<cluster> = '-'` to list snapshots for all clusters in an instance, e.g., + * `projects/<project>/instances/<instance>/clusters/-`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSnapshotsPagedResponse listSnapshots(String parent) { + ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder().setParent(parent).build(); + return listSnapshots(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all snapshots associated with the specified cluster. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Snapshot element : baseBigtableTableAdminClient.listSnapshots(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSnapshotsPagedResponse listSnapshots(ListSnapshotsRequest request) { + return listSnapshotsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all snapshots associated with the specified cluster. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListSnapshotsPagedResponse> future = baseBigtableTableAdminClient.listSnapshotsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Snapshot element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listSnapshotsPagedCallable() { + return stub.listSnapshotsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists all snapshots associated with the specified cluster. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListSnapshotsResponse response = baseBigtableTableAdminClient.listSnapshotsCallable().call(request);
+   *     for (Snapshot element : response.getSnapshotsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listSnapshotsCallable() { + return stub.listSnapshotsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   baseBigtableTableAdminClient.deleteSnapshot(name);
+   * }
+   * 
+ * + * @param name The unique name of the snapshot to be deleted. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSnapshot(SnapshotName name) { + + DeleteSnapshotRequest request = + DeleteSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteSnapshot(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   baseBigtableTableAdminClient.deleteSnapshot(name.toString());
+   * }
+   * 
+ * + * @param name The unique name of the snapshot to be deleted. Values are of the form + * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSnapshot(String name) { + + DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setName(name).build(); + deleteSnapshot(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   baseBigtableTableAdminClient.deleteSnapshot(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteSnapshot(DeleteSnapshotRequest request) { + deleteSnapshotCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Permanently deletes the specified snapshot. + * + *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not + * currently available to most Cloud Bigtable customers. This feature might be changed in + * backward-incompatible ways and is not recommended for production use. It is not subject to any + * SLA or deprecation policy. + * + *

Sample code: + * + *


+   * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
+   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+   *   DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = baseBigtableTableAdminClient.deleteSnapshotCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteSnapshotCallable() { + return stub.deleteSnapshotCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListTablesPagedResponse + extends AbstractPagedListResponse< + ListTablesRequest, ListTablesResponse, Table, ListTablesPage, + ListTablesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListTablesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListTablesPagedResponse apply(ListTablesPage input) { + return new ListTablesPagedResponse(input); + } + }); + } + + private ListTablesPagedResponse(ListTablesPage page) { + super(page, ListTablesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListTablesPage + extends AbstractPage { + + private ListTablesPage( + PageContext context, + ListTablesResponse response) { + super(context, response); + } + + private static ListTablesPage createEmptyPage() { + return new ListTablesPage(null, null); + } + + @Override + protected ListTablesPage createPage( + PageContext context, + ListTablesResponse response) { + return new ListTablesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListTablesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListTablesRequest, ListTablesResponse, Table, ListTablesPage, + ListTablesFixedSizeCollection> { + + private ListTablesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListTablesFixedSizeCollection createEmptyCollection() { + return new ListTablesFixedSizeCollection(null, 0); + } + + @Override + protected ListTablesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListTablesFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListSnapshotsPagedResponse + extends AbstractPagedListResponse< + ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage, + ListSnapshotsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListSnapshotsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListSnapshotsPagedResponse apply(ListSnapshotsPage input) { + return new ListSnapshotsPagedResponse(input); + } + }); + } + + private ListSnapshotsPagedResponse(ListSnapshotsPage page) { + super(page, ListSnapshotsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListSnapshotsPage + extends AbstractPage< + ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage> { + + private ListSnapshotsPage( + PageContext context, + ListSnapshotsResponse response) { + super(context, response); + } + + private static ListSnapshotsPage createEmptyPage() { + return new ListSnapshotsPage(null, null); + } + + @Override + protected ListSnapshotsPage createPage( + PageContext context, + ListSnapshotsResponse response) { + return new ListSnapshotsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListSnapshotsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage, + ListSnapshotsFixedSizeCollection> { + + private ListSnapshotsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListSnapshotsFixedSizeCollection createEmptyCollection() { + return new ListSnapshotsFixedSizeCollection(null, 0); + } + + @Override + protected ListSnapshotsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListSnapshotsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java new file mode 100644 index 000000000000..b11f94ff4c26 --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java @@ -0,0 +1,371 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.bigtable.admin.v2; + +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.bigtable.admin.v2.CheckConsistencyRequest; +import com.google.bigtable.admin.v2.CheckConsistencyResponse; +import com.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata; +import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; +import com.google.bigtable.admin.v2.CreateTableRequest; +import com.google.bigtable.admin.v2.DeleteSnapshotRequest; +import com.google.bigtable.admin.v2.DeleteTableRequest; +import com.google.bigtable.admin.v2.DropRowRangeRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; +import com.google.bigtable.admin.v2.GetSnapshotRequest; +import com.google.bigtable.admin.v2.GetTableRequest; +import com.google.bigtable.admin.v2.ListSnapshotsRequest; +import com.google.bigtable.admin.v2.ListSnapshotsResponse; +import com.google.bigtable.admin.v2.ListTablesRequest; +import com.google.bigtable.admin.v2.ListTablesResponse; +import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; +import com.google.bigtable.admin.v2.Snapshot; +import com.google.bigtable.admin.v2.SnapshotTableMetadata; +import com.google.bigtable.admin.v2.SnapshotTableRequest; +import com.google.bigtable.admin.v2.Table; +import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link BaseBigtableTableAdminClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (bigtableadmin.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of createTable to 30 seconds: + * + *

+ * 
+ * BaseBigtableTableAdminSettings.Builder baseBigtableTableAdminSettingsBuilder =
+ *     BaseBigtableTableAdminSettings.newBuilder();
+ * baseBigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings = baseBigtableTableAdminSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class BaseBigtableTableAdminSettings extends ClientSettings { + /** Returns the object with the settings used for calls to createTable. */ + public UnaryCallSettings createTableSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).createTableSettings(); + } + + /** Returns the object with the settings used for calls to createTableFromSnapshot. */ + public UnaryCallSettings + createTableFromSnapshotSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).createTableFromSnapshotSettings(); + } + + /** Returns the object with the settings used for calls to createTableFromSnapshot. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings< + CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> + createTableFromSnapshotOperationSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()) + .createTableFromSnapshotOperationSettings(); + } + + /** Returns the object with the settings used for calls to listTables. */ + public PagedCallSettings + listTablesSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).listTablesSettings(); + } + + /** Returns the object with the settings used for calls to getTable. */ + public UnaryCallSettings getTableSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).getTableSettings(); + } + + /** Returns the object with the settings used for calls to deleteTable. */ + public UnaryCallSettings deleteTableSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).deleteTableSettings(); + } + + /** Returns the object with the settings used for calls to modifyColumnFamilies. */ + public UnaryCallSettings modifyColumnFamiliesSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).modifyColumnFamiliesSettings(); + } + + /** Returns the object with the settings used for calls to dropRowRange. */ + public UnaryCallSettings dropRowRangeSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).dropRowRangeSettings(); + } + + /** Returns the object with the settings used for calls to generateConsistencyToken. */ + public UnaryCallSettings + generateConsistencyTokenSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).generateConsistencyTokenSettings(); + } + + /** Returns the object with the settings used for calls to checkConsistency. */ + public UnaryCallSettings + checkConsistencySettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).checkConsistencySettings(); + } + + /** Returns the object with the settings used for calls to snapshotTable. */ + public UnaryCallSettings snapshotTableSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).snapshotTableSettings(); + } + + /** Returns the object with the settings used for calls to snapshotTable. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings + snapshotTableOperationSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).snapshotTableOperationSettings(); + } + + /** Returns the object with the settings used for calls to getSnapshot. */ + public UnaryCallSettings getSnapshotSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).getSnapshotSettings(); + } + + /** Returns the object with the settings used for calls to listSnapshots. */ + public PagedCallSettings + listSnapshotsSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).listSnapshotsSettings(); + } + + /** Returns the object with the settings used for calls to deleteSnapshot. */ + public UnaryCallSettings deleteSnapshotSettings() { + return ((BigtableTableAdminStubSettings) getStubSettings()).deleteSnapshotSettings(); + } + + public static final BaseBigtableTableAdminSettings create(BigtableTableAdminStubSettings stub) + throws IOException { + return new BaseBigtableTableAdminSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return BigtableTableAdminStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return BigtableTableAdminStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return BigtableTableAdminStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return BigtableTableAdminStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return BigtableTableAdminStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return BigtableTableAdminStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return BigtableTableAdminStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected BaseBigtableTableAdminSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for BaseBigtableTableAdminSettings. */ + public static class Builder + extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(BigtableTableAdminStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(BigtableTableAdminStubSettings.newBuilder()); + } + + protected Builder(BaseBigtableTableAdminSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(BigtableTableAdminStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public BigtableTableAdminStubSettings.Builder getStubSettingsBuilder() { + return ((BigtableTableAdminStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to createTable. */ + public UnaryCallSettings.Builder createTableSettings() { + return getStubSettingsBuilder().createTableSettings(); + } + + /** Returns the builder for the settings used for calls to createTableFromSnapshot. */ + public UnaryCallSettings.Builder + createTableFromSnapshotSettings() { + return getStubSettingsBuilder().createTableFromSnapshotSettings(); + } + + /** Returns the builder for the settings used for calls to createTableFromSnapshot. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder< + CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> + createTableFromSnapshotOperationSettings() { + return getStubSettingsBuilder().createTableFromSnapshotOperationSettings(); + } + + /** Returns the builder for the settings used for calls to listTables. */ + public PagedCallSettings.Builder + listTablesSettings() { + return getStubSettingsBuilder().listTablesSettings(); + } + + /** Returns the builder for the settings used for calls to getTable. */ + public UnaryCallSettings.Builder getTableSettings() { + return getStubSettingsBuilder().getTableSettings(); + } + + /** Returns the builder for the settings used for calls to deleteTable. */ + public UnaryCallSettings.Builder deleteTableSettings() { + return getStubSettingsBuilder().deleteTableSettings(); + } + + /** Returns the builder for the settings used for calls to modifyColumnFamilies. */ + public UnaryCallSettings.Builder + modifyColumnFamiliesSettings() { + return getStubSettingsBuilder().modifyColumnFamiliesSettings(); + } + + /** Returns the builder for the settings used for calls to dropRowRange. */ + public UnaryCallSettings.Builder dropRowRangeSettings() { + return getStubSettingsBuilder().dropRowRangeSettings(); + } + + /** Returns the builder for the settings used for calls to generateConsistencyToken. */ + public UnaryCallSettings.Builder< + GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> + generateConsistencyTokenSettings() { + return getStubSettingsBuilder().generateConsistencyTokenSettings(); + } + + /** Returns the builder for the settings used for calls to checkConsistency. */ + public UnaryCallSettings.Builder + checkConsistencySettings() { + return getStubSettingsBuilder().checkConsistencySettings(); + } + + /** Returns the builder for the settings used for calls to snapshotTable. */ + public UnaryCallSettings.Builder snapshotTableSettings() { + return getStubSettingsBuilder().snapshotTableSettings(); + } + + /** Returns the builder for the settings used for calls to snapshotTable. */ + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder + snapshotTableOperationSettings() { + return getStubSettingsBuilder().snapshotTableOperationSettings(); + } + + /** Returns the builder for the settings used for calls to getSnapshot. */ + public UnaryCallSettings.Builder getSnapshotSettings() { + return getStubSettingsBuilder().getSnapshotSettings(); + } + + /** Returns the builder for the settings used for calls to listSnapshots. */ + public PagedCallSettings.Builder< + ListSnapshotsRequest, ListSnapshotsResponse, ListSnapshotsPagedResponse> + listSnapshotsSettings() { + return getStubSettingsBuilder().listSnapshotsSettings(); + } + + /** Returns the builder for the settings used for calls to deleteSnapshot. */ + public UnaryCallSettings.Builder deleteSnapshotSettings() { + return getStubSettingsBuilder().deleteSnapshotSettings(); + } + + @Override + public BaseBigtableTableAdminSettings build() throws IOException { + return new BaseBigtableTableAdminSettings(this); + } + } +} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java index 79e8e7d0bdd1..c6e2ecc38847 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java @@ -15,1966 +15,685 @@ */ package com.google.cloud.bigtable.admin.v2; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.longrunning.OperationFuture; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.bigtable.admin.v2.CheckConsistencyRequest; import com.google.bigtable.admin.v2.CheckConsistencyResponse; -import com.google.bigtable.admin.v2.ClusterName; -import com.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata; -import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; -import com.google.bigtable.admin.v2.CreateTableRequest; -import com.google.bigtable.admin.v2.DeleteSnapshotRequest; import com.google.bigtable.admin.v2.DeleteTableRequest; import com.google.bigtable.admin.v2.DropRowRangeRequest; +import com.google.bigtable.admin.v2.DropRowRangeRequest.Builder; import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; -import com.google.bigtable.admin.v2.GetSnapshotRequest; import com.google.bigtable.admin.v2.GetTableRequest; import com.google.bigtable.admin.v2.InstanceName; -import com.google.bigtable.admin.v2.ListSnapshotsRequest; -import com.google.bigtable.admin.v2.ListSnapshotsResponse; import com.google.bigtable.admin.v2.ListTablesRequest; import com.google.bigtable.admin.v2.ListTablesResponse; import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; -import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification; -import com.google.bigtable.admin.v2.Snapshot; -import com.google.bigtable.admin.v2.SnapshotName; -import com.google.bigtable.admin.v2.SnapshotTableMetadata; -import com.google.bigtable.admin.v2.SnapshotTableRequest; -import com.google.bigtable.admin.v2.Table; import com.google.bigtable.admin.v2.TableName; +import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.CreateTable; +import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.ModifyFamilies; +import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses; +import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken; +import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.Table; import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; -import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStubSettings; -import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.protobuf.ByteString; import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; +import javax.annotation.Nonnull; -// AUTO-GENERATED DOCUMENTATION AND SERVICE /** - * Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. + * Client for creating, configuring, and deleting Cloud Bigtable tables * *

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. * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. A "request object" method. This type of method only takes one parameter, a request object, - * which must be constructed before the call. Not every API method will have a request object - * method. - *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API - * callable object, which can be used to initiate calls to the service. - *
+ *

Sample code to get started: * - *

See the individual methods for example code. + *

{@code
+ * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+ *   CreateTable createTableReq =
+ *     TableAdminRequests.createTable("tableId")
+ *       .addFamily("cf1")
+ *       .addFamily("cf2", GCRULES.maxVersions(10))
+ *       .addSplit(ByteString.copyFromUtf8("b"))
+ *       .addSplit(ByteString.copyFromUtf8("q"));
+ *   client.createTable(createTableReq);
+ * }
+ * }
* - *

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. + *

Note: close() needs to be called on the client object to clean up resources such as threads. + * In the example above, try-with-resources is used, which automatically calls close(). * *

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);
- * 
- * 
+ *
{@code
+ * BigtableTableAdminSettings tableAdminSettings = BigtableTableAdminSettings.newBuilder()
+ *   .setInstanceName(InstanceName.of("[PROJECT]", "[INSTANCE]"))
+ *   .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *   .build();
+ *
+ * BigtableTableAdminClient client =
+ *   BigtableTableAdminClient.create(tableAdminSettings);
+ * }
* * To customize the endpoint: * - *
- * 
- * BigtableTableAdminSettings bigtableTableAdminSettings =
- *     BigtableTableAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * BigtableTableAdminClient bigtableTableAdminClient =
- *     BigtableTableAdminClient.create(bigtableTableAdminSettings);
- * 
- * 
+ *
{@code
+ * BigtableTableAdminSettings tableAdminSettings = BigtableTableAdminSettings.newBuilder()
+ *   .setInstanceName(InstanceName.of("[PROJECT]", "[INSTANCE]"))
+ *   .setEndpoint(myEndpoint).build();
+ *
+ * BigtableTableAdminClient client = BigtableTableAdminClient.create(tableAdminSettings);
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi -public class BigtableTableAdminClient implements BackgroundResource { - private final BigtableTableAdminSettings settings; +public class BigtableTableAdminClient implements AutoCloseable { private final BigtableTableAdminStub stub; - private final OperationsClient operationsClient; - - /** Constructs an instance of BigtableTableAdminClient with default settings. */ - public static final BigtableTableAdminClient create() throws IOException { - return create(BigtableTableAdminSettings.newBuilder().build()); - } + private final InstanceName instanceName; - /** - * Constructs an instance of BigtableTableAdminClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final BigtableTableAdminClient create(BigtableTableAdminSettings settings) - throws IOException { - return new BigtableTableAdminClient(settings); + /** Constructs an instance of BigtableTableAdminClient with the given instanceName. */ + public static BigtableTableAdminClient create(@Nonnull InstanceName instanceName) throws IOException { + return create(BigtableTableAdminSettings.newBuilder().setInstanceName(instanceName).build()); } - /** - * Constructs an instance of BigtableTableAdminClient, using the given stub for making calls. This - * is for advanced usage - prefer to use BigtableTableAdminSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final BigtableTableAdminClient create(BigtableTableAdminStub stub) { - return new BigtableTableAdminClient(stub); + /** Constructs an instance of BigtableTableAdminClient with the given settings. */ + public static BigtableTableAdminClient create(@Nonnull BigtableTableAdminSettings settings) throws IOException { + return create(settings.getInstanceName(), settings.getStubSettings().createStub()); } - /** - * Constructs an instance of BigtableTableAdminClient, using the given settings. This is protected - * so that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected BigtableTableAdminClient(BigtableTableAdminSettings settings) throws IOException { - this.settings = settings; - this.stub = ((BigtableTableAdminStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + /** Constructs an instance of BigtableTableAdminClient with the given instanceName and stub. */ + public static BigtableTableAdminClient create(@Nonnull InstanceName instanceName, @Nonnull BigtableTableAdminStub stub) { + return new BigtableTableAdminClient(instanceName, stub); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected BigtableTableAdminClient(BigtableTableAdminStub stub) { - this.settings = null; + private BigtableTableAdminClient(@Nonnull InstanceName instanceName, @Nonnull BigtableTableAdminStub stub) { + Preconditions.checkNotNull(instanceName); + Preconditions.checkNotNull(stub); + this.instanceName = instanceName; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); - } - - public final BigtableTableAdminSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public BigtableTableAdminStub getStub() { - return stub; - } - - /** - * Returns the OperationsClient that can be used to query the status of a long-running operation - * returned by another API method call. - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationsClient getOperationsClient() { - return operationsClient; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table in the specified instance. The table can be created with a full set of - * initial column families, specified in the request. - * - *

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);
-   * }
-   * 
- * - * @param parent The unique name of the instance in which to create the table. Values are of the - * form `projects/<project>/instances/<instance>`. - * @param tableId The name by which the new table should be referred to within the parent - * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. - * @param table The Table to create. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Table createTable(InstanceName parent, String tableId, Table table) { - - CreateTableRequest request = - CreateTableRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setTableId(tableId) - .setTable(table) - .build(); - return createTable(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table in the specified instance. The table can be created with a full set of - * initial column families, specified in the request. - * - *

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.toString(), tableId, table);
-   * }
-   * 
- * - * @param parent The unique name of the instance in which to create the table. Values are of the - * form `projects/<project>/instances/<instance>`. - * @param tableId The name by which the new table should be referred to within the parent - * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. - * @param table The Table to create. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Table createTable(String parent, String tableId, Table table) { - - CreateTableRequest request = - CreateTableRequest.newBuilder() - .setParent(parent) - .setTableId(tableId) - .setTable(table) - .build(); - return createTable(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table in the specified instance. The table can be created with a full set of - * initial column families, specified in the 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()
-   *     .setParent(parent.toString())
-   *     .setTableId(tableId)
-   *     .setTable(table)
-   *     .build();
-   *   Table response = bigtableTableAdminClient.createTable(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Table createTable(CreateTableRequest request) { - return createTableCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table in the specified instance. The table can be created with a full set of - * initial column families, specified in the 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()
-   *     .setParent(parent.toString())
-   *     .setTableId(tableId)
-   *     .setTable(table)
-   *     .build();
-   *   ApiFuture<Table> future = bigtableTableAdminClient.createTableCallable().futureCall(request);
-   *   // Do something
-   *   Table response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createTableCallable() { - return stub.createTableCallable(); + /** Gets the instanceName this client is associated with. */ + public InstanceName getInstanceName() { + return instanceName; } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table from the specified snapshot. The target table must not exist. The snapshot - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String tableId = "";
-   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
-   * }
-   * 
- * - * @param parent The unique name of the instance in which to create the table. Values are of the - * form `projects/<project>/instances/<instance>`. - * @param tableId The name by which the new table should be referred to within the parent - * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. - * @param sourceSnapshot The unique name of the snapshot from which to restore the table. The - * snapshot and the table must be in the same instance. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createTableFromSnapshotAsync( - InstanceName parent, String tableId, SnapshotName sourceSnapshot) { - - CreateTableFromSnapshotRequest request = - CreateTableFromSnapshotRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setTableId(tableId) - .setSourceSnapshot(sourceSnapshot == null ? null : sourceSnapshot.toString()) - .build(); - return createTableFromSnapshotAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table from the specified snapshot. The target table must not exist. The snapshot - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String tableId = "";
-   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(parent.toString(), tableId, sourceSnapshot.toString()).get();
-   * }
-   * 
- * - * @param parent The unique name of the instance in which to create the table. Values are of the - * form `projects/<project>/instances/<instance>`. - * @param tableId The name by which the new table should be referred to within the parent - * instance, e.g., `foobar` rather than `<parent>/tables/foobar`. - * @param sourceSnapshot The unique name of the snapshot from which to restore the table. The - * snapshot and the table must be in the same instance. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createTableFromSnapshotAsync( - String parent, String tableId, String sourceSnapshot) { - - CreateTableFromSnapshotRequest request = - CreateTableFromSnapshotRequest.newBuilder() - .setParent(parent) - .setTableId(tableId) - .setSourceSnapshot(sourceSnapshot) - .build(); - return createTableFromSnapshotAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table from the specified snapshot. The target table must not exist. The snapshot - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String tableId = "";
-   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setTableId(tableId)
-   *     .setSourceSnapshot(sourceSnapshot.toString())
-   *     .build();
-   *   Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(request).get();
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture createTableFromSnapshotAsync( - CreateTableFromSnapshotRequest request) { - return createTableFromSnapshotOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table from the specified snapshot. The target table must not exist. The snapshot - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String tableId = "";
-   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setTableId(tableId)
-   *     .setSourceSnapshot(sourceSnapshot.toString())
-   *     .build();
-   *   OperationFuture<Operation> future = bigtableTableAdminClient.createTableFromSnapshotOperationCallable().futureCall(request);
-   *   // Do something
-   *   Table response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable< - CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> - createTableFromSnapshotOperationCallable() { - return stub.createTableFromSnapshotOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new table from the specified snapshot. The target table must not exist. The snapshot - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   String tableId = "";
-   *   SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setTableId(tableId)
-   *     .setSourceSnapshot(sourceSnapshot.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = bigtableTableAdminClient.createTableFromSnapshotCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - createTableFromSnapshotCallable() { - return stub.createTableFromSnapshotCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all tables served from a specified instance. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (Table element : bigtableTableAdminClient.listTables(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent The unique name of the instance for which tables should be listed. Values are of - * the form `projects/<project>/instances/<instance>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListTablesPagedResponse listTables(InstanceName parent) { - ListTablesRequest request = - ListTablesRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); - return listTables(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all tables served from a specified instance. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   for (Table element : bigtableTableAdminClient.listTables(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent The unique name of the instance for which tables should be listed. Values are of - * the form `projects/<project>/instances/<instance>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListTablesPagedResponse listTables(String parent) { - ListTablesRequest request = ListTablesRequest.newBuilder().setParent(parent).build(); - return listTables(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all tables served from a specified instance. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListTablesRequest request = ListTablesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (Table element : bigtableTableAdminClient.listTables(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListTablesPagedResponse listTables(ListTablesRequest request) { - return listTablesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all tables served from a specified instance. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListTablesRequest request = ListTablesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListTablesPagedResponse> future = bigtableTableAdminClient.listTablesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Table element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable listTablesPagedCallable() { - return stub.listTablesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all tables served from a specified instance. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
-   *   ListTablesRequest request = ListTablesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 UnaryCallable listTablesCallable() { - return stub.listTablesCallable(); + @Override + public void close() { + stub.close(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified table. + * Creates a new table with the specified configuration * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   Table response = bigtableTableAdminClient.getTable(name);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   CreateTable createTableReq =
+   *     TableAdminRequests.createTable("tableId")
+   *       .addFamily("cf2", GCRULES.maxVersions(10))
+   *   client.createTable(createTableReq);
    * }
-   * 
+ * }
* - * @param name The unique name of the requested table. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param createTable + * @return the newly created table + * @see CreateTable for createTable configurations */ - public final Table getTable(TableName name) { - - GetTableRequest request = - GetTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getTable(request); + public Table createTable(CreateTable createTable) { + com.google.bigtable.admin.v2.Table table = + this.stub.createTableCallable().call(createTable.toProto(instanceName)); + return TableAdminResponses.convertTable(table); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified table. + * Creates a new table with the specified configuration asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   Table response = bigtableTableAdminClient.getTable(name.toString());
-   * }
-   * 
+ *
{@code
+   *  try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *    CreateTable createTableReq =
+   *      TableAdminRequests.createTable("tableId")
+   *        .addFamily("cf2", GCRULES.maxVersions(10))
+   *    client.createTableAsync(createTableReq);
+   *  }
+   *  }
* - * @param name The unique name of the requested table. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param createTable + * @return the newly created table + * @see CreateTable for createTable configurations */ - public final Table getTable(String name) { - - GetTableRequest request = GetTableRequest.newBuilder().setName(name).build(); - return getTable(request); + public ApiFuture createTableAsync(CreateTable createTable) { + return transformToTableResponse( + this.stub.createTableCallable().futureCall(createTable.toProto(instanceName))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified table. + * Creates, Updates and drops ColumnFamilies as per the request. * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GetTableRequest request = GetTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Table response = bigtableTableAdminClient.getTable(request);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
+   *     .addFamily("mf1")
+   *     .addFamily(
+   *       "mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
+   *     .updateFamily(
+   *       "mf1",
+   *          GCRULES
+   *            .union()
+   *              .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
+   *              .rule(GCRULES.maxVersions(1)))
+   *     .addFamily(
+   *       "mf3",
+   *         GCRULES
+   *           .intersection()
+   *           .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
+   *           .rule(GCRULES.maxVersions(10)))
+   *     .dropFamily("mf1")
+   *    client.modifyFamilies(modifyFamiliesReq);
    * }
-   * 
+ * }
* - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Table getTable(GetTableRequest request) { - return getTableCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets metadata information about the specified table. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GetTableRequest request = GetTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Table> future = bigtableTableAdminClient.getTableCallable().futureCall(request);
-   *   // Do something
-   *   Table response = future.get();
-   * }
-   * 
+ * @param modifyFamily + * @return the modified table + * @see ModifyFamilies for modifyFamily options */ - public final UnaryCallable getTableCallable() { - return stub.getTableCallable(); + public Table modifyFamilies(ModifyFamilies modifyFamily) { + ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName); + com.google.bigtable.admin.v2.Table table = + this.stub.modifyColumnFamiliesCallable().call(modReq); + return TableAdminResponses.convertTable(table); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes a specified table and all of its data. + * Creates, Updates and drops ColumnFamilies as per the request asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   bigtableTableAdminClient.deleteTable(name);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
+   *     .addFamily("mf1")
+   *     .addFamily(
+   *       "mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
+   *     .updateFamily(
+   *       "mf1",
+   *          GCRULES
+   *            .union()
+   *              .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
+   *              .rule(GCRULES.maxVersions(1)))
+   *     .addFamily(
+   *       "mf3",
+   *         GCRULES
+   *           .intersection()
+   *           .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
+   *           .rule(GCRULES.maxVersions(10)))
+   *     .dropFamily("mf1")
+   *    client.modifyFamilies(modifyFamiliesReq);
    * }
-   * 
+ * }
* - * @param name The unique name of the table to be deleted. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param modifyFamily + * @return Modified table + * @see ModifyFamilies for modifyFamily options */ - public final void deleteTable(TableName name) { - - DeleteTableRequest request = - DeleteTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteTable(request); + public ApiFuture
modifyFamiliesAsync(ModifyFamilies modifyFamily) { + ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName); + return transformToTableResponse(this.stub.modifyColumnFamiliesCallable().futureCall(modReq)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes a specified table and all of its data. + * Deletes the specified tableId * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   bigtableTableAdminClient.deleteTable(name.toString());
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.deleteTable("tableId");
    * }
-   * 
+ * }
* - * @param name The unique name of the table to be deleted. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final void deleteTable(String name) { - - DeleteTableRequest request = DeleteTableRequest.newBuilder().setName(name).build(); - deleteTable(request); + public void deleteTable(String tableId) { + this.stub.deleteTableCallable().call(composeDeleteTableRequest(tableId)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes a specified table and all of its data. + * Deletes the specified tableId asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   DeleteTableRequest request = DeleteTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   bigtableTableAdminClient.deleteTable(request);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.deleteTableAsync("tableId");
    * }
-   * 
+ * }
* - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - private final void deleteTable(DeleteTableRequest request) { - deleteTableCallable().call(request); + public ApiFuture deleteTableAsync(String tableId) { + return transformToVoid( + this.stub.deleteTableCallable().futureCall(composeDeleteTableRequest(tableId))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes a specified table and all of its data. + * Gets the Table by tableId * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   DeleteTableRequest request = DeleteTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = bigtableTableAdminClient.deleteTableCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.getTable("tableId");
    * }
-   * 
- */ - public final UnaryCallable deleteTableCallable() { - return stub.deleteTableCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Performs a series of column family modifications on the specified table. Either all or none of - * the modifications will occur before this method returns, but data requests received prior to - * that point may see a table where only some modifications have taken effect. + * }
* - *

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);
-   * }
-   * 
- * - * @param name The unique name of the table whose families should be modified. Values are of the - * form `projects/<project>/instances/<instance>/tables/<table>`. - * @param 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). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final Table modifyColumnFamilies( - TableName name, List modifications) { - - ModifyColumnFamiliesRequest request = - ModifyColumnFamiliesRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .addAllModifications(modifications) - .build(); - return modifyColumnFamilies(request); + public Table getTable(String tableId) { + com.google.bigtable.admin.v2.Table table = + this.stub.getTableCallable().call(composeGetTableRequest(tableId)); + return TableAdminResponses.convertTable(table); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Performs a series of column family modifications on the specified table. Either all or none of - * the modifications will occur before this method returns, but data requests received prior to - * that point may see a table where only some modifications have taken effect. + * Gets the Table by tableId * *

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.toString(), modifications);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.getTableAsync("tableId");
    * }
-   * 
- * - * @param name The unique name of the table whose families should be modified. Values are of the - * form `projects/<project>/instances/<instance>/tables/<table>`. - * @param 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). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Table modifyColumnFamilies( - String name, List modifications) { - - ModifyColumnFamiliesRequest request = - ModifyColumnFamiliesRequest.newBuilder() - .setName(name) - .addAllModifications(modifications) - .build(); - return modifyColumnFamilies(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Performs a series of column family modifications on the specified table. Either all or none of - * the modifications will occur before this method returns, but data requests received prior to - * that point may see a table where only some modifications have taken effect. + * }
* - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
-   *   ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .addAllModifications(modifications)
-   *     .build();
-   *   Table response = bigtableTableAdminClient.modifyColumnFamilies(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final Table modifyColumnFamilies(ModifyColumnFamiliesRequest request) { - return modifyColumnFamiliesCallable().call(request); + public ApiFuture
getTableAsync(String tableId) { + return transformToTableResponse( + this.stub.getTableCallable().futureCall(composeGetTableRequest(tableId))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Performs a series of column family modifications on the specified table. Either all or none of - * the modifications will occur before this method returns, but data requests received prior to - * that point may see a table where only some modifications have taken effect. + * Lists all TableNames in the instance. * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   List<ModifyColumnFamiliesRequest.Modification> modifications = new ArrayList<>();
-   *   ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .addAllModifications(modifications)
-   *     .build();
-   *   ApiFuture<Table> future = bigtableTableAdminClient.modifyColumnFamiliesCallable().futureCall(request);
-   *   // Do something
-   *   Table response = future.get();
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.listTables();
    * }
-   * 
+ * }
*/ - public final UnaryCallable modifyColumnFamiliesCallable() { - return stub.modifyColumnFamiliesCallable(); + public List listTables() { + ListTablesResponse listResp = this.stub.listTablesCallable().call(composeListTableRequest()); + return convertToTableNames(listResp); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently drop/delete a row range from a specified table. The request can specify whether to - * delete all rows in a table, or only those that match a particular prefix. + * Lists all TableNames in the instance asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   bigtableTableAdminClient.dropRowRange(request);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.listTablesAsync();
    * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * }
*/ - public final void dropRowRange(DropRowRangeRequest request) { - dropRowRangeCallable().call(request); - } + public ApiFuture> listTablesAsync() { + ApiFuture listResp = + this.stub.listTablesCallable().futureCall(composeListTableRequest()); - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Permanently drop/delete a row range from a specified table. The request can specify whether to - * delete all rows in a table, or only those that match a particular prefix. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   DropRowRangeRequest request = DropRowRangeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = bigtableTableAdminClient.dropRowRangeCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable dropRowRangeCallable() { - return stub.dropRowRangeCallable(); + return ApiFutures.transform( + listResp, + new ApiFunction>() { + @Override + public List apply(ListTablesResponse input) { + return convertToTableNames(input); + } + }); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Generates a consistency token for a Table, which can be used in CheckConsistency to check - * whether mutations to the table that finished before this call started have been replicated. The - * tokens will be available for 90 days. + * Drops rows by the specified key prefix and tableId * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GenerateConsistencyTokenResponse response = bigtableTableAdminClient.generateConsistencyToken(name);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropRowRange("tableId");
    * }
-   * 
+ * }
* - * @param name The unique name of the Table for which to create a consistency token. Values are of - * the form `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param rowKeyPrefix */ - public final GenerateConsistencyTokenResponse generateConsistencyToken(TableName name) { - - GenerateConsistencyTokenRequest request = - GenerateConsistencyTokenRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return generateConsistencyToken(request); + public void dropRowRange(String tableId, String rowKeyPrefix) { + dropRowRange(tableId, ByteString.copyFromUtf8(rowKeyPrefix)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Generates a consistency token for a Table, which can be used in CheckConsistency to check - * whether mutations to the table that finished before this call started have been replicated. The - * tokens will be available for 90 days. + * Drops rows by the specified key prefix and tableId asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GenerateConsistencyTokenResponse response = bigtableTableAdminClient.generateConsistencyToken(name.toString());
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropRowRangeAsync("tableId");
    * }
-   * 
+ * }
* - * @param name The unique name of the Table for which to create a consistency token. Values are of - * the form `projects/<project>/instances/<instance>/tables/<table>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param rowKeyPrefix */ - public final GenerateConsistencyTokenResponse generateConsistencyToken(String name) { - - GenerateConsistencyTokenRequest request = - GenerateConsistencyTokenRequest.newBuilder().setName(name).build(); - return generateConsistencyToken(request); + public ApiFuture dropRowRangeAsync(String tableId, String rowKeyPrefix) { + return dropRowRangeAsync(tableId, ByteString.copyFromUtf8(rowKeyPrefix)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Generates a consistency token for a Table, which can be used in CheckConsistency to check - * whether mutations to the table that finished before this call started have been replicated. The - * tokens will be available for 90 days. + * Drops rows by the specified key prefix and tableId * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   GenerateConsistencyTokenResponse response = bigtableTableAdminClient.generateConsistencyToken(request);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropRowRange("tableId");
    * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - private final GenerateConsistencyTokenResponse generateConsistencyToken( - GenerateConsistencyTokenRequest request) { - return generateConsistencyTokenCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Generates a consistency token for a Table, which can be used in CheckConsistency to check - * whether mutations to the table that finished before this call started have been replicated. The - * tokens will be available for 90 days. - * - *

Sample code: + * }

* - *

-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<GenerateConsistencyTokenResponse> future = bigtableTableAdminClient.generateConsistencyTokenCallable().futureCall(request);
-   *   // Do something
-   *   GenerateConsistencyTokenResponse response = future.get();
-   * }
-   * 
+ * @param tableId + * @param rowKeyPrefix */ - public final UnaryCallable - generateConsistencyTokenCallable() { - return stub.generateConsistencyTokenCallable(); + public void dropRowRange(String tableId, ByteString rowKeyPrefix) { + this.stub.dropRowRangeCallable().call(composeDropRowRangeRequest(tableId, rowKeyPrefix, false)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Checks replication consistency based on a consistency token, that is, if replication has caught - * up based on the conditions specified in the token and the check request. + * Drops rows by the specified key prefix and tableId * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   String consistencyToken = "";
-   *   CheckConsistencyResponse response = bigtableTableAdminClient.checkConsistency(name, consistencyToken);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropRowRangeAsync("tableId");
    * }
-   * 
+ * }
* - * @param name The unique name of the Table for which to check replication consistency. Values are - * of the form `projects/<project>/instances/<instance>/tables/<table>`. - * @param consistencyToken The token created using GenerateConsistencyToken for the Table. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param rowKeyPrefix */ - public final CheckConsistencyResponse checkConsistency(TableName name, String consistencyToken) { - - CheckConsistencyRequest request = - CheckConsistencyRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setConsistencyToken(consistencyToken) - .build(); - return checkConsistency(request); + public ApiFuture dropRowRangeAsync(String tableId, ByteString rowKeyPrefix) { + return transformToVoid( + this.stub + .dropRowRangeCallable() + .futureCall(composeDropRowRangeRequest(tableId, rowKeyPrefix, false))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Checks replication consistency based on a consistency token, that is, if replication has caught - * up based on the conditions specified in the token and the check request. + * Drops all data in the table * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   String consistencyToken = "";
-   *   CheckConsistencyResponse response = bigtableTableAdminClient.checkConsistency(name.toString(), consistencyToken);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropAllRows("tableId");
    * }
-   * 
+ * }
* - * @param name The unique name of the Table for which to check replication consistency. Values are - * of the form `projects/<project>/instances/<instance>/tables/<table>`. - * @param consistencyToken The token created using GenerateConsistencyToken for the Table. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final CheckConsistencyResponse checkConsistency(String name, String consistencyToken) { - - CheckConsistencyRequest request = - CheckConsistencyRequest.newBuilder() - .setName(name) - .setConsistencyToken(consistencyToken) - .build(); - return checkConsistency(request); + public void dropAllRows(String tableId) { + this.stub.dropRowRangeCallable().call(composeDropRowRangeRequest(tableId, null, true)); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Checks replication consistency based on a consistency token, that is, if replication has caught - * up based on the conditions specified in the token and the check request. + * Drops all data in the table asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   String consistencyToken = "";
-   *   CheckConsistencyRequest request = CheckConsistencyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConsistencyToken(consistencyToken)
-   *     .build();
-   *   CheckConsistencyResponse response = bigtableTableAdminClient.checkConsistency(request);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   client.dropAllRowsAsync("tableId");
    * }
-   * 
+ * }
* - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final CheckConsistencyResponse checkConsistency(CheckConsistencyRequest request) { - return checkConsistencyCallable().call(request); + public ApiFuture dropAllRowsAsync(String tableId) { + return transformToVoid( + this.stub + .dropRowRangeCallable() + .futureCall(composeDropRowRangeRequest(tableId, null, true))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Checks replication consistency based on a consistency token, that is, if replication has caught - * up based on the conditions specified in the token and the check request. + * Generates a token to verify the replication status of table mutations invoked before this call. + * Token expires in 90 days * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   String consistencyToken = "";
-   *   CheckConsistencyRequest request = CheckConsistencyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConsistencyToken(consistencyToken)
-   *     .build();
-   *   ApiFuture<CheckConsistencyResponse> future = bigtableTableAdminClient.checkConsistencyCallable().futureCall(request);
-   *   // Do something
-   *   CheckConsistencyResponse response = future.get();
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   ConsistencyToken consistencyToken = client.generateConsistencyToken("tableId");
    * }
-   * 
- */ - public final UnaryCallable - checkConsistencyCallable() { - return stub.checkConsistencyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new snapshot in the specified cluster from the specified source table. The cluster - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * }

* - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   String description = "";
-   *   Snapshot response = bigtableTableAdminClient.snapshotTableAsync(name, cluster, snapshotId, description).get();
-   * }
-   * 
- * - * @param name The unique name of the table to have the snapshot taken. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param cluster The name of the cluster where the snapshot will be created in. Values are of the - * form `projects/<project>/instances/<instance>/clusters/<cluster>`. - * @param snapshotId The ID by which the new snapshot should be referred to within the parent - * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`. - * @param description Description of the snapshot. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture snapshotTableAsync( - TableName name, ClusterName cluster, SnapshotName snapshotId, String description) { - - SnapshotTableRequest request = - SnapshotTableRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setCluster(cluster == null ? null : cluster.toString()) - .setSnapshotId(snapshotId == null ? null : snapshotId.toString()) - .setDescription(description) - .build(); - return snapshotTableAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new snapshot in the specified cluster from the specified source table. The cluster - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   String description = "";
-   *   Snapshot response = bigtableTableAdminClient.snapshotTableAsync(name.toString(), cluster.toString(), snapshotId.toString(), description).get();
-   * }
-   * 
- * - * @param name The unique name of the table to have the snapshot taken. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param cluster The name of the cluster where the snapshot will be created in. Values are of the - * form `projects/<project>/instances/<instance>/clusters/<cluster>`. - * @param snapshotId The ID by which the new snapshot should be referred to within the parent - * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`. - * @param description Description of the snapshot. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture snapshotTableAsync( - String name, String cluster, String snapshotId, String description) { - - SnapshotTableRequest request = - SnapshotTableRequest.newBuilder() - .setName(name) - .setCluster(cluster) - .setSnapshotId(snapshotId) - .setDescription(description) - .build(); - return snapshotTableAsync(request); + public ConsistencyToken generateConsistencyToken(String tableId) { + return TableAdminResponses.convertTokenResponse( + this.stub + .generateConsistencyTokenCallable() + .call(composeGenerateConsistencyTokenRequest(tableId))); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new snapshot in the specified cluster from the specified source table. The cluster - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Generates a token to verify the replication status of table mutations invoked before this call + * asynchronously Token expires in 90 days * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   String description = "";
-   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setCluster(cluster.toString())
-   *     .setSnapshotId(snapshotId.toString())
-   *     .setDescription(description)
-   *     .build();
-   *   Snapshot response = bigtableTableAdminClient.snapshotTableAsync(request).get();
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   ConsistencyToken consistencyToken = client.generateConsistencyToken("tableId");
    * }
-   * 
+ * }
* - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture snapshotTableAsync( - SnapshotTableRequest request) { - return snapshotTableOperationCallable().futureCall(request); - } + public ApiFuture generateConsistencyTokenAsync(String tableId) { + ApiFuture tokenResp = + this.stub + .generateConsistencyTokenCallable() + .futureCall(composeGenerateConsistencyTokenRequest(tableId)); - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new snapshot in the specified cluster from the specified source table. The cluster - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   String description = "";
-   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setCluster(cluster.toString())
-   *     .setSnapshotId(snapshotId.toString())
-   *     .setDescription(description)
-   *     .build();
-   *   OperationFuture<Operation> future = bigtableTableAdminClient.snapshotTableOperationCallable().futureCall(request);
-   *   // Do something
-   *   Snapshot response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - snapshotTableOperationCallable() { - return stub.snapshotTableOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new snapshot in the specified cluster from the specified source table. The cluster - * and the table must be in the same instance. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   String description = "";
-   *   SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setCluster(cluster.toString())
-   *     .setSnapshotId(snapshotId.toString())
-   *     .setDescription(description)
-   *     .build();
-   *   ApiFuture<Operation> future = bigtableTableAdminClient.snapshotTableCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable snapshotTableCallable() { - return stub.snapshotTableCallable(); + return ApiFutures.transform( + tokenResp, + new ApiFunction() { + @Override + public ConsistencyToken apply(GenerateConsistencyTokenResponse input) { + return TableAdminResponses.convertTokenResponse(input); + } + }); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Checks replication consistency for the specified token consistency token * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   Snapshot response = bigtableTableAdminClient.getSnapshot(name);
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   boolean consistent = client.isConsistent("tableId", token);
    * }
-   * 
+ * }
* - * @param name The unique name of the requested snapshot. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param token */ - public final Snapshot getSnapshot(SnapshotName name) { - - GetSnapshotRequest request = - GetSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getSnapshot(request); + public boolean isConsistent(String tableId, ConsistencyToken token) { + return stub.checkConsistencyCallable() + .call(token.toProto(getTableName(tableId))) + .getConsistent(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Checks replication consistency for the specified token consistency token asynchronously * *

Sample code: * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   Snapshot response = bigtableTableAdminClient.getSnapshot(name.toString());
+   * 
{@code
+   * try(BigtableTableAdminClient client =  BigtableTableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
+   *   boolean consistent = client.isConsistentAsync("tableId", token);
    * }
-   * 
+ * }
* - * @param name The unique name of the requested snapshot. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param token */ - public final Snapshot getSnapshot(String name) { + public ApiFuture isConsistentAsync(String tableId, ConsistencyToken token) { + ApiFuture checkConsResp = + stub.checkConsistencyCallable().futureCall(token.toProto(getTableName(tableId))); - GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setName(name).build(); - return getSnapshot(request); + return ApiFutures.transform( + checkConsResp, + new ApiFunction() { + @Override + public Boolean apply(CheckConsistencyResponse input) { + return input.getConsistent(); + } + }); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: + * Helper method to construct the table name in format: + * projects/{project}/instances/{instance}/tables/{tableId} * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   GetSnapshotRequest request = GetSnapshotRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Snapshot response = bigtableTableAdminClient.getSnapshot(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @return unique table name */ - private final Snapshot getSnapshot(GetSnapshotRequest request) { - return getSnapshotCallable().call(request); + @VisibleForTesting + String getTableName(String tableId) { + return TableName.of(instanceName.getProject(), instanceName.getInstance(), tableId).toString(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets metadata information about the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   GetSnapshotRequest request = GetSnapshotRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Snapshot> future = bigtableTableAdminClient.getSnapshotCallable().futureCall(request);
-   *   // Do something
-   *   Snapshot response = future.get();
-   * }
-   * 
+ * Helper method to build an instance of ListTablesRequest */ - public final UnaryCallable getSnapshotCallable() { - return stub.getSnapshotCallable(); + @VisibleForTesting + ListTablesRequest composeListTableRequest() { + return ListTablesRequest.newBuilder().setParent(instanceName.toString()).build(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists all snapshots associated with the specified cluster. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   for (Snapshot element : bigtableTableAdminClient.listSnapshots(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * Helper method to build an instance of GetTableRequest * - * @param parent The unique name of the cluster for which snapshots should be listed. Values are - * of the form `projects/<project>/instances/<instance>/clusters/<cluster>`. - * Use `<cluster> = '-'` to list snapshots for all clusters in an instance, e.g., - * `projects/<project>/instances/<instance>/clusters/-`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final ListSnapshotsPagedResponse listSnapshots(ClusterName parent) { - ListSnapshotsRequest request = - ListSnapshotsRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .build(); - return listSnapshots(request); + @VisibleForTesting + GetTableRequest composeGetTableRequest(String tableId) { + return GetTableRequest.newBuilder().setName(getTableName(tableId)).build(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists all snapshots associated with the specified cluster. + * Helper method to build an instance of DeleteTableRequest * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   for (Snapshot element : bigtableTableAdminClient.listSnapshots(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent The unique name of the cluster for which snapshots should be listed. Values are - * of the form `projects/<project>/instances/<instance>/clusters/<cluster>`. - * Use `<cluster> = '-'` to list snapshots for all clusters in an instance, e.g., - * `projects/<project>/instances/<instance>/clusters/-`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final ListSnapshotsPagedResponse listSnapshots(String parent) { - ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder().setParent(parent).build(); - return listSnapshots(request); + @VisibleForTesting + DeleteTableRequest composeDeleteTableRequest(String tableId) { + return DeleteTableRequest.newBuilder().setName(getTableName(tableId)).build(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists all snapshots associated with the specified cluster. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Helper method to build an instance of DropRowRangeRequest * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (Snapshot element : bigtableTableAdminClient.listSnapshots(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId + * @param rowKeyPrefix + * @param boolean dropAll */ - public final ListSnapshotsPagedResponse listSnapshots(ListSnapshotsRequest request) { - return listSnapshotsPagedCallable().call(request); - } + @VisibleForTesting + DropRowRangeRequest composeDropRowRangeRequest( + String tableId, ByteString rowKeyPrefix, boolean dropAll) { + Builder dropRowReq = DropRowRangeRequest.newBuilder().setName(getTableName(tableId)); - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all snapshots associated with the specified cluster. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListSnapshotsPagedResponse> future = bigtableTableAdminClient.listSnapshotsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Snapshot element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listSnapshotsPagedCallable() { - return stub.listSnapshotsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists all snapshots associated with the specified cluster. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. - * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
-   *   ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListSnapshotsResponse response = bigtableTableAdminClient.listSnapshotsCallable().call(request);
-   *     for (Snapshot element : response.getSnapshotsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable listSnapshotsCallable() { - return stub.listSnapshotsCallable(); + if (dropAll) { + dropRowReq.setDeleteAllDataFromTable(true); + } else { + dropRowReq.setRowKeyPrefix(rowKeyPrefix); + } + return dropRowReq.build(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Helper method to build an instance of GenerateConsistencyTokenRequest * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   bigtableTableAdminClient.deleteSnapshot(name);
-   * }
-   * 
- * - * @param name The unique name of the snapshot to be deleted. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param tableId */ - public final void deleteSnapshot(SnapshotName name) { - - DeleteSnapshotRequest request = - DeleteSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteSnapshot(request); + @VisibleForTesting + GenerateConsistencyTokenRequest composeGenerateConsistencyTokenRequest(String tableId) { + return GenerateConsistencyTokenRequest.newBuilder().setName(getTableName(tableId)).build(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Helper method to convert ListTablesResponse to List * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   bigtableTableAdminClient.deleteSnapshot(name.toString());
-   * }
-   * 
- * - * @param name The unique name of the snapshot to be deleted. Values are of the form - * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param listTablesResponse */ - public final void deleteSnapshot(String name) { + @VisibleForTesting + static List convertToTableNames(ListTablesResponse listTablesResponse) { + List tableNames = new ArrayList<>(); - DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setName(name).build(); - deleteSnapshot(request); + for (com.google.bigtable.admin.v2.Table table : listTablesResponse.getTablesList()) { + tableNames.add(TableName.parse(table.getName())); + } + return tableNames; } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Helper method to transform ApiFuture to ApiFuture

* - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   bigtableTableAdminClient.deleteSnapshot(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails + * @param future */ - private final void deleteSnapshot(DeleteSnapshotRequest request) { - deleteSnapshotCallable().call(request); + @VisibleForTesting + static ApiFuture
transformToTableResponse( + ApiFuture future) { + return ApiFutures.transform( + future, + new ApiFunction() { + @Override + public Table apply(com.google.bigtable.admin.v2.Table table) { + return TableAdminResponses.convertTable(table); + } + }); } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Permanently deletes the specified snapshot. - * - *

Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not - * currently available to most Cloud Bigtable customers. This feature might be changed in - * backward-incompatible ways and is not recommended for production use. It is not subject to any - * SLA or deprecation policy. + * Helper method to transform ApiFuture to ApiFuture * - *

Sample code: - * - *


-   * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
-   *   SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
-   *   DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = bigtableTableAdminClient.deleteSnapshotCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
+ * @param future */ - public final UnaryCallable deleteSnapshotCallable() { - return stub.deleteSnapshotCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListTablesPagedResponse - extends AbstractPagedListResponse< - ListTablesRequest, ListTablesResponse, Table, ListTablesPage, - ListTablesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListTablesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListTablesPagedResponse apply(ListTablesPage input) { - return new ListTablesPagedResponse(input); - } - }); - } - - private ListTablesPagedResponse(ListTablesPage page) { - super(page, ListTablesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListTablesPage - extends AbstractPage { - - private ListTablesPage( - PageContext context, - ListTablesResponse response) { - super(context, response); - } - - private static ListTablesPage createEmptyPage() { - return new ListTablesPage(null, null); - } - - @Override - protected ListTablesPage createPage( - PageContext context, - ListTablesResponse response) { - return new ListTablesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListTablesFixedSizeCollection - extends AbstractFixedSizeCollection< - ListTablesRequest, ListTablesResponse, Table, ListTablesPage, - ListTablesFixedSizeCollection> { - - private ListTablesFixedSizeCollection(List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListTablesFixedSizeCollection createEmptyCollection() { - return new ListTablesFixedSizeCollection(null, 0); - } - - @Override - protected ListTablesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListTablesFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListSnapshotsPagedResponse - extends AbstractPagedListResponse< - ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage, - ListSnapshotsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListSnapshotsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListSnapshotsPagedResponse apply(ListSnapshotsPage input) { - return new ListSnapshotsPagedResponse(input); - } - }); - } - - private ListSnapshotsPagedResponse(ListSnapshotsPage page) { - super(page, ListSnapshotsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListSnapshotsPage - extends AbstractPage< - ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage> { - - private ListSnapshotsPage( - PageContext context, - ListSnapshotsResponse response) { - super(context, response); - } - - private static ListSnapshotsPage createEmptyPage() { - return new ListSnapshotsPage(null, null); - } - - @Override - protected ListSnapshotsPage createPage( - PageContext context, - ListSnapshotsResponse response) { - return new ListSnapshotsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListSnapshotsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListSnapshotsRequest, ListSnapshotsResponse, Snapshot, ListSnapshotsPage, - ListSnapshotsFixedSizeCollection> { - - private ListSnapshotsFixedSizeCollection(List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListSnapshotsFixedSizeCollection createEmptyCollection() { - return new ListSnapshotsFixedSizeCollection(null, 0); - } - - @Override - protected ListSnapshotsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListSnapshotsFixedSizeCollection(pages, collectionSize); - } + @VisibleForTesting + static ApiFuture transformToVoid(ApiFuture future) { + return ApiFutures.transform( + future, + new ApiFunction() { + @Override + public Void apply(Empty empty) { + return null; + } + }); } } diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java index ef3e2f867530..16a296ef0eee 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java @@ -15,213 +15,52 @@ */ package com.google.cloud.bigtable.admin.v2; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListSnapshotsPagedResponse; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListTablesPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.bigtable.admin.v2.CheckConsistencyRequest; -import com.google.bigtable.admin.v2.CheckConsistencyResponse; -import com.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata; -import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; -import com.google.bigtable.admin.v2.CreateTableRequest; -import com.google.bigtable.admin.v2.DeleteSnapshotRequest; -import com.google.bigtable.admin.v2.DeleteTableRequest; -import com.google.bigtable.admin.v2.DropRowRangeRequest; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; -import com.google.bigtable.admin.v2.GetSnapshotRequest; -import com.google.bigtable.admin.v2.GetTableRequest; -import com.google.bigtable.admin.v2.ListSnapshotsRequest; -import com.google.bigtable.admin.v2.ListSnapshotsResponse; -import com.google.bigtable.admin.v2.ListTablesRequest; -import com.google.bigtable.admin.v2.ListTablesResponse; -import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; -import com.google.bigtable.admin.v2.Snapshot; -import com.google.bigtable.admin.v2.SnapshotTableMetadata; -import com.google.bigtable.admin.v2.SnapshotTableRequest; -import com.google.bigtable.admin.v2.Table; +import com.google.bigtable.admin.v2.InstanceName; import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStubSettings; -import com.google.longrunning.Operation; -import com.google.protobuf.Empty; +import com.google.common.base.Preconditions; +import com.google.common.base.Verify; import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -// AUTO-GENERATED DOCUMENTATION AND CLASS /** * Settings class to configure an instance of {@link BigtableTableAdminClient}. * - *

The default instance has everything set to sensible defaults: + *

It must be configured with an {@link InstanceName} and be used to change default RPC settings. + * + *

Example usage: * - *

    - *
  • The default service address (bigtableadmin.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
+ *
{@code
+ * BigtableTableAdminSettings.Builder tableAdminSettingsBuilder = BigtableTableAdminSettings.newBuilder()
+ *   .setInstanceName(InstanceName.of("my-project", "my-instance");
  *
- * 

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. For - * example, to set the total timeout of createTable to 30 seconds: + * tableAdminSettingsBuilder.stubSettings().createTableSettings() + * .setRetrySettings( + * RetrySettings.newBuilder() + * .setTotalTimeout(Duration.ofMinutes(15)) + * .build()); * - *

- * 
- * BigtableTableAdminSettings.Builder bigtableTableAdminSettingsBuilder =
- *     BigtableTableAdminSettings.newBuilder();
- * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BigtableTableAdminSettings bigtableTableAdminSettings = bigtableTableAdminSettingsBuilder.build();
- * 
- * 
+ * BigtableTableAdminSettings tableAdminSettings = tableAdminSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") -@BetaApi -public class BigtableTableAdminSettings extends ClientSettings { - /** Returns the object with the settings used for calls to createTable. */ - public UnaryCallSettings createTableSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).createTableSettings(); - } - - /** Returns the object with the settings used for calls to createTableFromSnapshot. */ - public UnaryCallSettings - createTableFromSnapshotSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).createTableFromSnapshotSettings(); - } - - /** Returns the object with the settings used for calls to createTableFromSnapshot. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings< - CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> - createTableFromSnapshotOperationSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()) - .createTableFromSnapshotOperationSettings(); - } - - /** Returns the object with the settings used for calls to listTables. */ - public PagedCallSettings - listTablesSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).listTablesSettings(); - } - - /** Returns the object with the settings used for calls to getTable. */ - public UnaryCallSettings getTableSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).getTableSettings(); - } +public final class BigtableTableAdminSettings { + private final InstanceName instanceName; + private final BigtableTableAdminStubSettings stubSettings; - /** Returns the object with the settings used for calls to deleteTable. */ - public UnaryCallSettings deleteTableSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).deleteTableSettings(); + private BigtableTableAdminSettings(Builder builder) throws IOException { + this.instanceName = Preconditions.checkNotNull(builder.instanceName, "InstanceName must be set"); + this.stubSettings = Verify.verifyNotNull(builder.stubSettings, "stubSettings should never be null").build(); } - /** Returns the object with the settings used for calls to modifyColumnFamilies. */ - public UnaryCallSettings modifyColumnFamiliesSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).modifyColumnFamiliesSettings(); + /** Gets the name of instance whose tables the client will manage. */ + @Nonnull + public InstanceName getInstanceName() { + return instanceName; } - /** Returns the object with the settings used for calls to dropRowRange. */ - public UnaryCallSettings dropRowRangeSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).dropRowRangeSettings(); - } - - /** Returns the object with the settings used for calls to generateConsistencyToken. */ - public UnaryCallSettings - generateConsistencyTokenSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).generateConsistencyTokenSettings(); - } - - /** Returns the object with the settings used for calls to checkConsistency. */ - public UnaryCallSettings - checkConsistencySettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).checkConsistencySettings(); - } - - /** Returns the object with the settings used for calls to snapshotTable. */ - public UnaryCallSettings snapshotTableSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).snapshotTableSettings(); - } - - /** Returns the object with the settings used for calls to snapshotTable. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings - snapshotTableOperationSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).snapshotTableOperationSettings(); - } - - /** Returns the object with the settings used for calls to getSnapshot. */ - public UnaryCallSettings getSnapshotSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).getSnapshotSettings(); - } - - /** Returns the object with the settings used for calls to listSnapshots. */ - public PagedCallSettings - listSnapshotsSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).listSnapshotsSettings(); - } - - /** Returns the object with the settings used for calls to deleteSnapshot. */ - public UnaryCallSettings deleteSnapshotSettings() { - return ((BigtableTableAdminStubSettings) getStubSettings()).deleteSnapshotSettings(); - } - - public static final BigtableTableAdminSettings create(BigtableTableAdminStubSettings stub) - throws IOException { - return new BigtableTableAdminSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return BigtableTableAdminStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return BigtableTableAdminStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return BigtableTableAdminStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return BigtableTableAdminStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return BigtableTableAdminStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return BigtableTableAdminStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return BigtableTableAdminStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); + /** Gets the underlying RPC settings. */ + public BigtableTableAdminStubSettings getStubSettings() { + return stubSettings; } /** Returns a builder containing all the values of this settings class. */ @@ -229,140 +68,50 @@ public Builder toBuilder() { return new Builder(this); } - protected BigtableTableAdminSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return new Builder(); } /** Builder for BigtableTableAdminSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } + public static final class Builder { + @Nullable + private InstanceName instanceName; + private final BigtableTableAdminStubSettings.Builder stubSettings; - protected Builder(ClientContext clientContext) { - super(BigtableTableAdminStubSettings.newBuilder(clientContext)); + private Builder() { + stubSettings = BigtableTableAdminStubSettings.newBuilder(); } - private static Builder createDefault() { - return new Builder(BigtableTableAdminStubSettings.newBuilder()); + private Builder(BigtableTableAdminSettings settings) { + this.instanceName = settings.instanceName; + this.stubSettings = settings.stubSettings.toBuilder(); } - protected Builder(BigtableTableAdminSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(BigtableTableAdminStubSettings.Builder stubSettings) { - super(stubSettings); + /** Sets the name of instance whose tables the client will manage. */ + public Builder setInstanceName(@Nonnull InstanceName instanceName) { + Preconditions.checkNotNull(instanceName); + this.instanceName = instanceName; + return this; } - public BigtableTableAdminStubSettings.Builder getStubSettingsBuilder() { - return ((BigtableTableAdminStubSettings.Builder) getStubSettings()); + /** Gets the name of instance whose tables the client will manage. */ + @Nullable + public InstanceName getInstanceName() { + return instanceName; } - // NEXT_MAJOR_VER: remove 'throws Exception' /** - * Applies the given settings updater function to all of the unary API methods in this service. + * Returns the builder for the settings used for all RPCs. * - *

Note: This method does not support applying settings to streaming methods. + *

This is meant for advanced usage. The default RPC settings are set to their recommended + * values. */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to createTable. */ - public UnaryCallSettings.Builder createTableSettings() { - return getStubSettingsBuilder().createTableSettings(); - } - - /** Returns the builder for the settings used for calls to createTableFromSnapshot. */ - public UnaryCallSettings.Builder - createTableFromSnapshotSettings() { - return getStubSettingsBuilder().createTableFromSnapshotSettings(); - } - - /** Returns the builder for the settings used for calls to createTableFromSnapshot. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder< - CreateTableFromSnapshotRequest, Table, CreateTableFromSnapshotMetadata> - createTableFromSnapshotOperationSettings() { - return getStubSettingsBuilder().createTableFromSnapshotOperationSettings(); - } - - /** Returns the builder for the settings used for calls to listTables. */ - public PagedCallSettings.Builder - listTablesSettings() { - return getStubSettingsBuilder().listTablesSettings(); - } - - /** Returns the builder for the settings used for calls to getTable. */ - public UnaryCallSettings.Builder getTableSettings() { - return getStubSettingsBuilder().getTableSettings(); - } - - /** Returns the builder for the settings used for calls to deleteTable. */ - public UnaryCallSettings.Builder deleteTableSettings() { - return getStubSettingsBuilder().deleteTableSettings(); - } - - /** Returns the builder for the settings used for calls to modifyColumnFamilies. */ - public UnaryCallSettings.Builder - modifyColumnFamiliesSettings() { - return getStubSettingsBuilder().modifyColumnFamiliesSettings(); - } - - /** Returns the builder for the settings used for calls to dropRowRange. */ - public UnaryCallSettings.Builder dropRowRangeSettings() { - return getStubSettingsBuilder().dropRowRangeSettings(); - } - - /** Returns the builder for the settings used for calls to generateConsistencyToken. */ - public UnaryCallSettings.Builder< - GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> - generateConsistencyTokenSettings() { - return getStubSettingsBuilder().generateConsistencyTokenSettings(); - } - - /** Returns the builder for the settings used for calls to checkConsistency. */ - public UnaryCallSettings.Builder - checkConsistencySettings() { - return getStubSettingsBuilder().checkConsistencySettings(); - } - - /** Returns the builder for the settings used for calls to snapshotTable. */ - public UnaryCallSettings.Builder snapshotTableSettings() { - return getStubSettingsBuilder().snapshotTableSettings(); - } - - /** Returns the builder for the settings used for calls to snapshotTable. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - snapshotTableOperationSettings() { - return getStubSettingsBuilder().snapshotTableOperationSettings(); - } - - /** Returns the builder for the settings used for calls to getSnapshot. */ - public UnaryCallSettings.Builder getSnapshotSettings() { - return getStubSettingsBuilder().getSnapshotSettings(); - } - - /** Returns the builder for the settings used for calls to listSnapshots. */ - public PagedCallSettings.Builder< - ListSnapshotsRequest, ListSnapshotsResponse, ListSnapshotsPagedResponse> - listSnapshotsSettings() { - return getStubSettingsBuilder().listSnapshotsSettings(); - } - - /** Returns the builder for the settings used for calls to deleteSnapshot. */ - public UnaryCallSettings.Builder deleteSnapshotSettings() { - return getStubSettingsBuilder().deleteSnapshotSettings(); + public BigtableTableAdminStubSettings.Builder stubSettings() { + return stubSettings; } - @Override + /** Builds an instance of the settings. */ public BigtableTableAdminSettings build() throws IOException { return new BigtableTableAdminSettings(this); } diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java deleted file mode 100644 index da24bd59fa79..000000000000 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminClient.java +++ /dev/null @@ -1,699 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigtable.admin.v2; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.bigtable.admin.v2.CheckConsistencyResponse; -import com.google.bigtable.admin.v2.DeleteTableRequest; -import com.google.bigtable.admin.v2.DropRowRangeRequest; -import com.google.bigtable.admin.v2.DropRowRangeRequest.Builder; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; -import com.google.bigtable.admin.v2.GetTableRequest; -import com.google.bigtable.admin.v2.InstanceName; -import com.google.bigtable.admin.v2.ListTablesRequest; -import com.google.bigtable.admin.v2.ListTablesResponse; -import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; -import com.google.bigtable.admin.v2.TableName; -import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.CreateTable; -import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.ModifyFamilies; -import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses; -import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken; -import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.Table; -import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.protobuf.ByteString; -import com.google.protobuf.Empty; -import javax.annotation.Nonnull; - -/** - * 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: - * - *

{@code
- * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
- *   CreateTable createTableReq =
- *     TableAdminRequests.createTable("tableId")
- *       .addFamily("cf1")
- *       .addFamily("cf2", GCRULES.maxVersions(10))
- *       .addSplit(ByteString.copyFromUtf8("b"))
- *       .addSplit(ByteString.copyFromUtf8("q"));
- *   client.createTable(createTableReq);
- * }
- * }
- * - *

Note: close() needs to be called on the client object to clean up resources such as threads. - * In the example above, try-with-resources is used, which automatically calls close(). - * - *

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

To customize credentials: - * - *

{@code
- * TableAdminSettings tableAdminSettings = TableAdminSettings.newBuilder()
- *   .setInstanceName(InstanceName.of("[PROJECT]", "[INSTANCE]"))
- *   .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *   .build();
- *
- * TableAdminClient client =
- *   TableAdminClient.create(tableAdminSettings);
- * }
- * - * To customize the endpoint: - * - *
{@code
- * TableAdminSettings tableAdminSettings = TableAdminSettings.newBuilder()
- *   .setInstanceName(InstanceName.of("[PROJECT]", "[INSTANCE]"))
- *   .setEndpoint(myEndpoint).build();
- *
- * TableAdminClient client = TableAdminClient.create(tableAdminSettings);
- * }
- */ -public class TableAdminClient implements AutoCloseable { - private final BigtableTableAdminStub stub; - private final InstanceName instanceName; - - /** Constructs an instance of TableAdminClient with the given instanceName. */ - public static TableAdminClient create(@Nonnull InstanceName instanceName) throws IOException { - return create(TableAdminSettings.newBuilder().setInstanceName(instanceName).build()); - } - - /** Constructs an instance of TableAdminClient with the given settings. */ - public static TableAdminClient create(@Nonnull TableAdminSettings settings) throws IOException { - return create(settings.getInstanceName(), settings.getStubSettings().createStub()); - } - - /** Constructs an instance of TableAdminClient with the given instanceName and stub. */ - public static TableAdminClient create(@Nonnull InstanceName instanceName, @Nonnull BigtableTableAdminStub stub) { - return new TableAdminClient(instanceName, stub); - } - - private TableAdminClient(@Nonnull InstanceName instanceName, @Nonnull BigtableTableAdminStub stub) { - Preconditions.checkNotNull(instanceName); - Preconditions.checkNotNull(stub); - this.instanceName = instanceName; - this.stub = stub; - } - - /** Gets the instanceName this client is associated with. */ - public InstanceName getInstanceName() { - return instanceName; - } - - @Override - public void close() { - stub.close(); - } - - /** - * Creates a new table with the specified configuration - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   CreateTable createTableReq =
-   *     TableAdminRequests.createTable("tableId")
-   *       .addFamily("cf2", GCRULES.maxVersions(10))
-   *   client.createTable(createTableReq);
-   * }
-   * }
- * - * @param createTable - * @return the newly created table - * @see CreateTable for createTable configurations - */ - public Table createTable(CreateTable createTable) { - com.google.bigtable.admin.v2.Table table = - this.stub.createTableCallable().call(createTable.toProto(instanceName)); - return TableAdminResponses.convertTable(table); - } - - /** - * Creates a new table with the specified configuration asynchronously - * - *

Sample code: - * - *

{@code
-   *  try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *    CreateTable createTableReq =
-   *      TableAdminRequests.createTable("tableId")
-   *        .addFamily("cf2", GCRULES.maxVersions(10))
-   *    client.createTableAsync(createTableReq);
-   *  }
-   *  }
- * - * @param createTable - * @return the newly created table - * @see CreateTable for createTable configurations - */ - public ApiFuture
createTableAsync(CreateTable createTable) { - return transformToTableResponse( - this.stub.createTableCallable().futureCall(createTable.toProto(instanceName))); - } - - /** - * Creates, Updates and drops ColumnFamilies as per the request. - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
-   *     .addFamily("mf1")
-   *     .addFamily(
-   *       "mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
-   *     .updateFamily(
-   *       "mf1",
-   *          GCRULES
-   *            .union()
-   *              .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
-   *              .rule(GCRULES.maxVersions(1)))
-   *     .addFamily(
-   *       "mf3",
-   *         GCRULES
-   *           .intersection()
-   *           .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
-   *           .rule(GCRULES.maxVersions(10)))
-   *     .dropFamily("mf1")
-   *    client.modifyFamilies(modifyFamiliesReq);
-   * }
-   * }
- * - * @param modifyFamily - * @return the modified table - * @see ModifyFamilies for modifyFamily options - */ - public Table modifyFamilies(ModifyFamilies modifyFamily) { - ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName); - com.google.bigtable.admin.v2.Table table = - this.stub.modifyColumnFamiliesCallable().call(modReq); - return TableAdminResponses.convertTable(table); - } - - /** - * Creates, Updates and drops ColumnFamilies as per the request asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   ModifyFamilies modifyFamiliesReq = TableAdminRequests.modifyFamilies(tableId)
-   *     .addFamily("mf1")
-   *     .addFamily(
-   *       "mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000)))
-   *     .updateFamily(
-   *       "mf1",
-   *          GCRULES
-   *            .union()
-   *              .rule(GCRULES.maxAge(Duration.ofSeconds(100)))
-   *              .rule(GCRULES.maxVersions(1)))
-   *     .addFamily(
-   *       "mf3",
-   *         GCRULES
-   *           .intersection()
-   *           .rule(GCRULES.maxAge(Duration.ofSeconds(2000)))
-   *           .rule(GCRULES.maxVersions(10)))
-   *     .dropFamily("mf1")
-   *    client.modifyFamilies(modifyFamiliesReq);
-   * }
-   * }
- * - * @param modifyFamily - * @return Modified table - * @see ModifyFamilies for modifyFamily options - */ - public ApiFuture
modifyFamiliesAsync(ModifyFamilies modifyFamily) { - ModifyColumnFamiliesRequest modReq = modifyFamily.toProto(instanceName); - return transformToTableResponse(this.stub.modifyColumnFamiliesCallable().futureCall(modReq)); - } - - /** - * Deletes the specified tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.deleteTable("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public void deleteTable(String tableId) { - this.stub.deleteTableCallable().call(composeDeleteTableRequest(tableId)); - } - - /** - * Deletes the specified tableId asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.deleteTableAsync("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public ApiFuture deleteTableAsync(String tableId) { - return transformToVoid( - this.stub.deleteTableCallable().futureCall(composeDeleteTableRequest(tableId))); - } - - /** - * Gets the Table by tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.getTable("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public Table getTable(String tableId) { - com.google.bigtable.admin.v2.Table table = - this.stub.getTableCallable().call(composeGetTableRequest(tableId)); - return TableAdminResponses.convertTable(table); - } - - /** - * Gets the Table by tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.getTableAsync("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public ApiFuture
getTableAsync(String tableId) { - return transformToTableResponse( - this.stub.getTableCallable().futureCall(composeGetTableRequest(tableId))); - } - - /** - * Lists all TableNames in the instance. - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.listTables();
-   * }
-   * }
- */ - public List listTables() { - ListTablesResponse listResp = this.stub.listTablesCallable().call(composeListTableRequest()); - return convertToTableNames(listResp); - } - - /** - * Lists all TableNames in the instance asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.listTablesAsync();
-   * }
-   * }
- */ - public ApiFuture> listTablesAsync() { - ApiFuture listResp = - this.stub.listTablesCallable().futureCall(composeListTableRequest()); - - return ApiFutures.transform( - listResp, - new ApiFunction>() { - @Override - public List apply(ListTablesResponse input) { - return convertToTableNames(input); - } - }); - } - - /** - * Drops rows by the specified key prefix and tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropRowRange("tableId");
-   * }
-   * }
- * - * @param tableId - * @param rowKeyPrefix - */ - public void dropRowRange(String tableId, String rowKeyPrefix) { - dropRowRange(tableId, ByteString.copyFromUtf8(rowKeyPrefix)); - } - - /** - * Drops rows by the specified key prefix and tableId asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropRowRangeAsync("tableId");
-   * }
-   * }
- * - * @param tableId - * @param rowKeyPrefix - */ - public ApiFuture dropRowRangeAsync(String tableId, String rowKeyPrefix) { - return dropRowRangeAsync(tableId, ByteString.copyFromUtf8(rowKeyPrefix)); - } - - /** - * Drops rows by the specified key prefix and tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropRowRange("tableId");
-   * }
-   * }
- * - * @param tableId - * @param rowKeyPrefix - */ - public void dropRowRange(String tableId, ByteString rowKeyPrefix) { - this.stub.dropRowRangeCallable().call(composeDropRowRangeRequest(tableId, rowKeyPrefix, false)); - } - - /** - * Drops rows by the specified key prefix and tableId - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropRowRangeAsync("tableId");
-   * }
-   * }
- * - * @param tableId - * @param rowKeyPrefix - */ - public ApiFuture dropRowRangeAsync(String tableId, ByteString rowKeyPrefix) { - return transformToVoid( - this.stub - .dropRowRangeCallable() - .futureCall(composeDropRowRangeRequest(tableId, rowKeyPrefix, false))); - } - - /** - * Drops all data in the table - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropAllRows("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public void dropAllRows(String tableId) { - this.stub.dropRowRangeCallable().call(composeDropRowRangeRequest(tableId, null, true)); - } - - /** - * Drops all data in the table asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   client.dropAllRowsAsync("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public ApiFuture dropAllRowsAsync(String tableId) { - return transformToVoid( - this.stub - .dropRowRangeCallable() - .futureCall(composeDropRowRangeRequest(tableId, null, true))); - } - - /** - * Generates a token to verify the replication status of table mutations invoked before this call. - * Token expires in 90 days - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   ConsistencyToken consistencyToken = client.generateConsistencyToken("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public ConsistencyToken generateConsistencyToken(String tableId) { - return TableAdminResponses.convertTokenResponse( - this.stub - .generateConsistencyTokenCallable() - .call(composeGenerateConsistencyTokenRequest(tableId))); - } - - /** - * Generates a token to verify the replication status of table mutations invoked before this call - * asynchronously Token expires in 90 days - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   ConsistencyToken consistencyToken = client.generateConsistencyToken("tableId");
-   * }
-   * }
- * - * @param tableId - */ - public ApiFuture generateConsistencyTokenAsync(String tableId) { - ApiFuture tokenResp = - this.stub - .generateConsistencyTokenCallable() - .futureCall(composeGenerateConsistencyTokenRequest(tableId)); - - return ApiFutures.transform( - tokenResp, - new ApiFunction() { - @Override - public ConsistencyToken apply(GenerateConsistencyTokenResponse input) { - return TableAdminResponses.convertTokenResponse(input); - } - }); - } - - /** - * Checks replication consistency for the specified token consistency token - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   boolean consistent = client.isConsistent("tableId", token);
-   * }
-   * }
- * - * @param tableId - * @param token - */ - public boolean isConsistent(String tableId, ConsistencyToken token) { - return stub.checkConsistencyCallable() - .call(token.toProto(getTableName(tableId))) - .getConsistent(); - } - - /** - * Checks replication consistency for the specified token consistency token asynchronously - * - *

Sample code: - * - *

{@code
-   * try(TableAdminClient client =  TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"))) {
-   *   boolean consistent = client.isConsistentAsync("tableId", token);
-   * }
-   * }
- * - * @param tableId - * @param token - */ - public ApiFuture isConsistentAsync(String tableId, ConsistencyToken token) { - ApiFuture checkConsResp = - stub.checkConsistencyCallable().futureCall(token.toProto(getTableName(tableId))); - - return ApiFutures.transform( - checkConsResp, - new ApiFunction() { - @Override - public Boolean apply(CheckConsistencyResponse input) { - return input.getConsistent(); - } - }); - } - - /** - * Helper method to construct the table name in format: - * projects/{project}/instances/{instance}/tables/{tableId} - * - * @param tableId - * @return unique table name - */ - @VisibleForTesting - String getTableName(String tableId) { - return TableName.of(instanceName.getProject(), instanceName.getInstance(), tableId).toString(); - } - - /** - * Helper method to build an instance of ListTablesRequest - */ - @VisibleForTesting - ListTablesRequest composeListTableRequest() { - return ListTablesRequest.newBuilder().setParent(instanceName.toString()).build(); - } - - /** - * Helper method to build an instance of GetTableRequest - * - * @param tableId - */ - @VisibleForTesting - GetTableRequest composeGetTableRequest(String tableId) { - return GetTableRequest.newBuilder().setName(getTableName(tableId)).build(); - } - - /** - * Helper method to build an instance of DeleteTableRequest - * - * @param tableId - */ - @VisibleForTesting - DeleteTableRequest composeDeleteTableRequest(String tableId) { - return DeleteTableRequest.newBuilder().setName(getTableName(tableId)).build(); - } - - /** - * Helper method to build an instance of DropRowRangeRequest - * - * @param tableId - * @param rowKeyPrefix - * @param boolean dropAll - */ - @VisibleForTesting - DropRowRangeRequest composeDropRowRangeRequest( - String tableId, ByteString rowKeyPrefix, boolean dropAll) { - Builder dropRowReq = DropRowRangeRequest.newBuilder().setName(getTableName(tableId)); - - if (dropAll) { - dropRowReq.setDeleteAllDataFromTable(true); - } else { - dropRowReq.setRowKeyPrefix(rowKeyPrefix); - } - return dropRowReq.build(); - } - - /** - * Helper method to build an instance of GenerateConsistencyTokenRequest - * - * @param tableId - */ - @VisibleForTesting - GenerateConsistencyTokenRequest composeGenerateConsistencyTokenRequest(String tableId) { - return GenerateConsistencyTokenRequest.newBuilder().setName(getTableName(tableId)).build(); - } - - /** - * Helper method to convert ListTablesResponse to List - * - * @param listTablesResponse - */ - @VisibleForTesting - static List convertToTableNames(ListTablesResponse listTablesResponse) { - List tableNames = new ArrayList<>(); - - for (com.google.bigtable.admin.v2.Table table : listTablesResponse.getTablesList()) { - tableNames.add(TableName.parse(table.getName())); - } - return tableNames; - } - - /** - * Helper method to transform ApiFuture to ApiFuture
- * - * @param future - */ - @VisibleForTesting - static ApiFuture
transformToTableResponse( - ApiFuture future) { - return ApiFutures.transform( - future, - new ApiFunction() { - @Override - public Table apply(com.google.bigtable.admin.v2.Table table) { - return TableAdminResponses.convertTable(table); - } - }); - } - - /** - * Helper method to transform ApiFuture to ApiFuture - * - * @param future - */ - @VisibleForTesting - static ApiFuture transformToVoid(ApiFuture future) { - return ApiFutures.transform( - future, - new ApiFunction() { - @Override - public Void apply(Empty empty) { - return null; - } - }); - } -} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminSettings.java deleted file mode 100644 index 4eea4bff59f4..000000000000 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/TableAdminSettings.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigtable.admin.v2; - -import com.google.bigtable.admin.v2.InstanceName; -import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStubSettings; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; -import java.io.IOException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * Settings class to configure an instance of {@link TableAdminClient}. - * - *

It must be configured with an {@link InstanceName} and be used to change default RPC settings. - * - *

Example usage: - * - *

{@code
- * TableAdminSettings.Builder tableAdminSettingsBuilder = TableAdminSettings.newBuilder()
- *   .setInstanceName(InstanceName.of("my-project", "my-instance");
- *
- * tableAdminSettingsBuilder.stubSettings().createTableSettings()
- *   .setRetrySettings(
- *     RetrySettings.newBuilder()
- *       .setTotalTimeout(Duration.ofMinutes(15))
- *       .build());
- *
- * BigtableTableAdminSettings tableAdminSettings = tableAdminSettingsBuilder.build();
- * }
- */ -public final class TableAdminSettings { - private final InstanceName instanceName; - private final BigtableTableAdminStubSettings stubSettings; - - private TableAdminSettings(Builder builder) throws IOException { - this.instanceName = Preconditions.checkNotNull(builder.instanceName, "InstanceName must be set"); - this.stubSettings = Verify.verifyNotNull(builder.stubSettings, "stubSettings should never be null").build(); - } - - /** Gets the name of instance whose tables the client will manage. */ - @Nonnull - public InstanceName getInstanceName() { - return instanceName; - } - - /** Gets the underlying RPC settings. */ - public BigtableTableAdminStubSettings getStubSettings() { - return stubSettings; - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return new Builder(); - } - - /** Builder for TableAdminSettings. */ - public static final class Builder { - @Nullable - private InstanceName instanceName; - private final BigtableTableAdminStubSettings.Builder stubSettings; - - private Builder() { - stubSettings = BigtableTableAdminStubSettings.newBuilder(); - } - - private Builder(TableAdminSettings settings) { - this.instanceName = settings.instanceName; - this.stubSettings = settings.stubSettings.toBuilder(); - } - - /** Sets the name of instance whose tables the client will manage. */ - public Builder setInstanceName(@Nonnull InstanceName instanceName) { - Preconditions.checkNotNull(instanceName); - this.instanceName = instanceName; - return this; - } - - /** Gets the name of instance whose tables the client will manage. */ - @Nullable - public InstanceName getInstanceName() { - return instanceName; - } - - /** - * Returns the builder for the settings used for all RPCs. - * - *

This is meant for advanced usage. The default RPC settings are set to their recommended - * values. - */ - public BigtableTableAdminStubSettings.Builder stubSettings() { - return stubSettings; - } - - /** Builds an instance of the settings. */ - public TableAdminSettings build() throws IOException { - return new TableAdminSettings(this); - } - } -} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java index 42b9f22a8ecb..170345a8b6b3 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/models/TableAdminResponses.java @@ -29,7 +29,7 @@ import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; import com.google.bigtable.admin.v2.Table.ClusterState.ReplicationState; import com.google.bigtable.admin.v2.TableName; -import com.google.cloud.bigtable.admin.v2.TableAdminClient; +import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient; import com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.IntersectionRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.UnionRule; @@ -269,7 +269,7 @@ private GCRule convertGcRule(GcRule source) { * Wrapper for {@link GenerateConsistencyTokenResponse#getConsistencyToken()} * *

Cannot be created. They are obtained by invoking {@link - * TableAdminClient#generateConsistencyToken(String)} + * BigtableTableAdminClient#generateConsistencyToken(String)} */ public static final class ConsistencyToken { private final String token; diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java index 868792c432d4..64642f97400f 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java @@ -19,38 +19,39 @@ * *

The interfaces provided are listed below, along with usage samples. * - *

=========================== BigtableInstanceAdminClient =========================== + *

=============================== BaseBigtableInstanceAdminClient + * =============================== * *

Service Description: Service for creating, configuring, and deleting Cloud Bigtable Instances * and Clusters. Provides access to the Instance and Cluster schemas only, not the tables' metadata * or data stored in those tables. * - *

Sample for BigtableInstanceAdminClient: + *

Sample for BaseBigtableInstanceAdminClient: * *

  * 
- * try (BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.create()) {
+ * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
  *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
- *   Instance response = bigtableInstanceAdminClient.getInstance(name);
+ *   Instance response = baseBigtableInstanceAdminClient.getInstance(name);
  * }
  * 
  * 
* - * ======================== BigtableTableAdminClient ======================== + * ============================ BaseBigtableTableAdminClient ============================ * *

Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. * *

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

Sample for BigtableTableAdminClient: + *

Sample for BaseBigtableTableAdminClient: * *

  * 
- * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
+ * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
  *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
  *   String tableId = "";
  *   Table table = Table.newBuilder().build();
- *   Table response = bigtableTableAdminClient.createTable(parent, tableId, table);
+ *   Table response = baseBigtableTableAdminClient.createTable(parent, tableId, table);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java index aaccdb4d5045..181b8e2beb97 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient.ListAppProfilesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java index c24aa6a73ea8..844f33a1f9e3 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient.ListAppProfilesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -102,11 +102,11 @@ * *
  * 
- * BigtableInstanceAdminStubSettings.Builder bigtableInstanceAdminSettingsBuilder =
+ * BigtableInstanceAdminStubSettings.Builder baseBigtableInstanceAdminSettingsBuilder =
  *     BigtableInstanceAdminStubSettings.newBuilder();
- * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
+ * baseBigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
  *     .setTotalTimeout(Duration.ofSeconds(30));
- * BigtableInstanceAdminStubSettings bigtableInstanceAdminSettings = bigtableInstanceAdminSettingsBuilder.build();
+ * BigtableInstanceAdminStubSettings baseBigtableInstanceAdminSettings = baseBigtableInstanceAdminSettingsBuilder.build();
  * 
  * 
*/ diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java index f1a4d26078e4..0c12b84d4a5f 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java @@ -15,8 +15,8 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListSnapshotsPagedResponse; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListTablesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java index 1713def0773c..3ce8c07eb061 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java @@ -15,8 +15,8 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListSnapshotsPagedResponse; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListTablesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -94,11 +94,11 @@ * *
  * 
- * BigtableTableAdminStubSettings.Builder bigtableTableAdminSettingsBuilder =
+ * BigtableTableAdminStubSettings.Builder baseBigtableTableAdminSettingsBuilder =
  *     BigtableTableAdminStubSettings.newBuilder();
- * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
+ * baseBigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
  *     .setTotalTimeout(Duration.ofSeconds(30));
- * BigtableTableAdminStubSettings bigtableTableAdminSettings = bigtableTableAdminSettingsBuilder.build();
+ * BigtableTableAdminStubSettings baseBigtableTableAdminSettings = baseBigtableTableAdminSettingsBuilder.build();
  * 
  * 
*/ diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java index 82c29c13b08e..7175c6b8428a 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient.ListAppProfilesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java index 8313842143d6..a5b1d69146ba 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java @@ -15,8 +15,8 @@ */ package com.google.cloud.bigtable.admin.v2.stub; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListSnapshotsPagedResponse; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListTablesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClientTest.java similarity index 98% rename from google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java rename to google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClientTest.java index b8c2cf94275d..0e083776f040 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClientTest.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.admin.v2; -import static com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient.ListAppProfilesPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; @@ -79,11 +79,11 @@ import org.junit.Test; @javax.annotation.Generated("by GAPIC") -public class BigtableInstanceAdminClientTest { +public class BaseBigtableInstanceAdminClientTest { private static MockBigtableInstanceAdmin mockBigtableInstanceAdmin; private static MockBigtableTableAdmin mockBigtableTableAdmin; private static MockServiceHelper serviceHelper; - private BigtableInstanceAdminClient client; + private BaseBigtableInstanceAdminClient client; private LocalChannelProvider channelProvider; @BeforeClass @@ -106,12 +106,12 @@ public static void stopServer() { public void setUp() throws IOException { serviceHelper.reset(); channelProvider = serviceHelper.createChannelProvider(); - BigtableInstanceAdminSettings settings = - BigtableInstanceAdminSettings.newBuilder() + BaseBigtableInstanceAdminSettings settings = + BaseBigtableInstanceAdminSettings.newBuilder() .setTransportChannelProvider(channelProvider) .setCredentialsProvider(NoCredentialsProvider.create()) .build(); - client = BigtableInstanceAdminClient.create(settings); + client = BaseBigtableInstanceAdminClient.create(settings); } @After diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClientTest.java new file mode 100644 index 000000000000..0d6218ff724a --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClientTest.java @@ -0,0 +1,659 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.bigtable.admin.v2; + +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.bigtable.admin.v2.CheckConsistencyRequest; +import com.google.bigtable.admin.v2.CheckConsistencyResponse; +import com.google.bigtable.admin.v2.ClusterName; +import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; +import com.google.bigtable.admin.v2.CreateTableRequest; +import com.google.bigtable.admin.v2.DeleteSnapshotRequest; +import com.google.bigtable.admin.v2.DeleteTableRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; +import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; +import com.google.bigtable.admin.v2.GetSnapshotRequest; +import com.google.bigtable.admin.v2.GetTableRequest; +import com.google.bigtable.admin.v2.InstanceName; +import com.google.bigtable.admin.v2.ListSnapshotsRequest; +import com.google.bigtable.admin.v2.ListSnapshotsResponse; +import com.google.bigtable.admin.v2.ListTablesRequest; +import com.google.bigtable.admin.v2.ListTablesResponse; +import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; +import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification; +import com.google.bigtable.admin.v2.Snapshot; +import com.google.bigtable.admin.v2.SnapshotName; +import com.google.bigtable.admin.v2.SnapshotTableRequest; +import com.google.bigtable.admin.v2.Table; +import com.google.bigtable.admin.v2.TableName; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class BaseBigtableTableAdminClientTest { + private static MockBigtableInstanceAdmin mockBigtableInstanceAdmin; + private static MockBigtableTableAdmin mockBigtableTableAdmin; + private static MockServiceHelper serviceHelper; + private BaseBigtableTableAdminClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockBigtableInstanceAdmin = new MockBigtableInstanceAdmin(); + mockBigtableTableAdmin = new MockBigtableTableAdmin(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList(mockBigtableInstanceAdmin, mockBigtableTableAdmin)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + BaseBigtableTableAdminSettings settings = + BaseBigtableTableAdminSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = BaseBigtableTableAdminClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void createTableTest() { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + Table expectedResponse = Table.newBuilder().setName(name.toString()).build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String tableId = "tableId-895419604"; + Table table = Table.newBuilder().build(); + + Table actualResponse = client.createTable(parent, tableId, table); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateTableRequest actualRequest = (CreateTableRequest) actualRequests.get(0); + + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertEquals(tableId, actualRequest.getTableId()); + Assert.assertEquals(table, actualRequest.getTable()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createTableExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String tableId = "tableId-895419604"; + Table table = Table.newBuilder().build(); + + client.createTable(parent, tableId, table); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createTableFromSnapshotTest() throws Exception { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + Table expectedResponse = Table.newBuilder().setName(name.toString()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTableFromSnapshotTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockBigtableTableAdmin.addResponse(resultOperation); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String tableId = "tableId-895419604"; + SnapshotName sourceSnapshot = + SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + Table actualResponse = + client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateTableFromSnapshotRequest actualRequest = + (CreateTableFromSnapshotRequest) actualRequests.get(0); + + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertEquals(tableId, actualRequest.getTableId()); + Assert.assertEquals(sourceSnapshot, SnapshotName.parse(actualRequest.getSourceSnapshot())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createTableFromSnapshotExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + String tableId = "tableId-895419604"; + SnapshotName sourceSnapshot = + SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void listTablesTest() { + String nextPageToken = ""; + Table tablesElement = Table.newBuilder().build(); + List
tables = Arrays.asList(tablesElement); + ListTablesResponse expectedResponse = + ListTablesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllTables(tables) + .build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + + ListTablesPagedResponse pagedListResponse = client.listTables(parent); + + List
resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTablesList().get(0), resources.get(0)); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListTablesRequest actualRequest = (ListTablesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listTablesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); + + client.listTables(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getTableTest() { + TableName name2 = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + Table expectedResponse = Table.newBuilder().setName(name2.toString()).build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + Table actualResponse = client.getTable(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetTableRequest actualRequest = (GetTableRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getTableExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + client.getTable(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteTableTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + client.deleteTable(name); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteTableRequest actualRequest = (DeleteTableRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteTableExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + client.deleteTable(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void modifyColumnFamiliesTest() { + TableName name2 = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + Table expectedResponse = Table.newBuilder().setName(name2.toString()).build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + List modifications = new ArrayList<>(); + + Table actualResponse = client.modifyColumnFamilies(name, modifications); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ModifyColumnFamiliesRequest actualRequest = (ModifyColumnFamiliesRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertEquals(modifications, actualRequest.getModificationsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void modifyColumnFamiliesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + List modifications = new ArrayList<>(); + + client.modifyColumnFamilies(name, modifications); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void generateConsistencyTokenTest() { + String consistencyToken = "consistencyToken-1090516718"; + GenerateConsistencyTokenResponse expectedResponse = + GenerateConsistencyTokenResponse.newBuilder().setConsistencyToken(consistencyToken).build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + GenerateConsistencyTokenResponse actualResponse = client.generateConsistencyToken(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GenerateConsistencyTokenRequest actualRequest = + (GenerateConsistencyTokenRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void generateConsistencyTokenExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + + client.generateConsistencyToken(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void checkConsistencyTest() { + boolean consistent = true; + CheckConsistencyResponse expectedResponse = + CheckConsistencyResponse.newBuilder().setConsistent(consistent).build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + String consistencyToken = "consistencyToken-1090516718"; + + CheckConsistencyResponse actualResponse = client.checkConsistency(name, consistencyToken); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CheckConsistencyRequest actualRequest = (CheckConsistencyRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertEquals(consistencyToken, actualRequest.getConsistencyToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void checkConsistencyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + String consistencyToken = "consistencyToken-1090516718"; + + client.checkConsistency(name, consistencyToken); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void snapshotTableTest() throws Exception { + SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + long dataSizeBytes = 2110122398L; + String description2 = "description2568623279"; + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(name2.toString()) + .setDataSizeBytes(dataSizeBytes) + .setDescription(description2) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("snapshotTableTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockBigtableTableAdmin.addResponse(resultOperation); + + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); + SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + String description = "description-1724546052"; + + Snapshot actualResponse = + client.snapshotTableAsync(name, cluster, snapshotId, description).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SnapshotTableRequest actualRequest = (SnapshotTableRequest) actualRequests.get(0); + + Assert.assertEquals(name, TableName.parse(actualRequest.getName())); + Assert.assertEquals(cluster, ClusterName.parse(actualRequest.getCluster())); + Assert.assertEquals(snapshotId, SnapshotName.parse(actualRequest.getSnapshotId())); + Assert.assertEquals(description, actualRequest.getDescription()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void snapshotTableExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); + ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); + SnapshotName snapshotId = + SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + String description = "description-1724546052"; + + client.snapshotTableAsync(name, cluster, snapshotId, description).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void getSnapshotTest() { + SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + long dataSizeBytes = 2110122398L; + String description = "description-1724546052"; + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(name2.toString()) + .setDataSizeBytes(dataSizeBytes) + .setDescription(description) + .build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + Snapshot actualResponse = client.getSnapshot(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetSnapshotRequest actualRequest = (GetSnapshotRequest) actualRequests.get(0); + + Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getSnapshotExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + client.getSnapshot(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listSnapshotsTest() { + String nextPageToken = ""; + Snapshot snapshotsElement = Snapshot.newBuilder().build(); + List snapshots = Arrays.asList(snapshotsElement); + ListSnapshotsResponse expectedResponse = + ListSnapshotsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllSnapshots(snapshots) + .build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); + + ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListSnapshotsRequest actualRequest = (ListSnapshotsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ClusterName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listSnapshotsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); + + client.listSnapshots(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteSnapshotTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockBigtableTableAdmin.addResponse(expectedResponse); + + SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + client.deleteSnapshot(name); + + List actualRequests = mockBigtableTableAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteSnapshotRequest actualRequest = (DeleteSnapshotRequest) actualRequests.get(0); + + Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteSnapshotExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockBigtableTableAdmin.addException(exception); + + try { + SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); + + client.deleteSnapshot(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } +} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java index b1820ecd17b4..d11b3f6d5695 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java @@ -15,645 +15,291 @@ */ package com.google.cloud.bigtable.admin.v2; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListSnapshotsPagedResponse; -import static com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient.ListTablesPagedResponse; - -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.api.gax.rpc.StatusCode; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.UnaryCallable; import com.google.bigtable.admin.v2.CheckConsistencyRequest; import com.google.bigtable.admin.v2.CheckConsistencyResponse; -import com.google.bigtable.admin.v2.ClusterName; -import com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest; import com.google.bigtable.admin.v2.CreateTableRequest; -import com.google.bigtable.admin.v2.DeleteSnapshotRequest; import com.google.bigtable.admin.v2.DeleteTableRequest; +import com.google.bigtable.admin.v2.DropRowRangeRequest; import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; -import com.google.bigtable.admin.v2.GetSnapshotRequest; import com.google.bigtable.admin.v2.GetTableRequest; import com.google.bigtable.admin.v2.InstanceName; -import com.google.bigtable.admin.v2.ListSnapshotsRequest; -import com.google.bigtable.admin.v2.ListSnapshotsResponse; import com.google.bigtable.admin.v2.ListTablesRequest; import com.google.bigtable.admin.v2.ListTablesResponse; import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; -import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest.Modification; -import com.google.bigtable.admin.v2.Snapshot; -import com.google.bigtable.admin.v2.SnapshotName; -import com.google.bigtable.admin.v2.SnapshotTableRequest; import com.google.bigtable.admin.v2.Table; import com.google.bigtable.admin.v2.TableName; -import com.google.common.collect.Lists; -import com.google.longrunning.Operation; -import com.google.protobuf.Any; +import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests; +import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.CreateTable; +import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.ModifyFamilies; +import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken; +import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; +import com.google.protobuf.ByteString; import com.google.protobuf.Empty; -import com.google.protobuf.GeneratedMessageV3; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@RunWith(MockitoJUnitRunner.class) public class BigtableTableAdminClientTest { - private static MockBigtableInstanceAdmin mockBigtableInstanceAdmin; - private static MockBigtableTableAdmin mockBigtableTableAdmin; - private static MockServiceHelper serviceHelper; - private BigtableTableAdminClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockBigtableInstanceAdmin = new MockBigtableInstanceAdmin(); - mockBigtableTableAdmin = new MockBigtableTableAdmin(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList(mockBigtableInstanceAdmin, mockBigtableTableAdmin)); - serviceHelper.start(); - } + private BigtableTableAdminClient adminClient; + @Mock private BigtableTableAdminStub mockStub; - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } + @Mock private UnaryCallable mockCreateTableCallable; + @Mock private UnaryCallable mockModifyTableCallable; + @Mock private UnaryCallable mockDeleteTableCallable; + @Mock private UnaryCallable mockGetTableCallable; + @Mock private UnaryCallable mockListTableCallable; + @Mock private UnaryCallable mockDropRowRangeCallable; - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - BigtableTableAdminSettings settings = - BigtableTableAdminSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = BigtableTableAdminClient.create(settings); - } + @Mock + private UnaryCallable + mockGenerateConsistencyTokenCallable; - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void createTableTest() { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - Table expectedResponse = Table.newBuilder().setName(name.toString()).build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String tableId = "tableId-895419604"; - Table table = Table.newBuilder().build(); + @Mock + private UnaryCallable + mockCheckConsistencyCallable; - Table actualResponse = client.createTable(parent, tableId, table); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateTableRequest actualRequest = (CreateTableRequest) actualRequests.get(0); - - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertEquals(tableId, actualRequest.getTableId()); - Assert.assertEquals(table, actualRequest.getTable()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createTableExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String tableId = "tableId-895419604"; - Table table = Table.newBuilder().build(); - - client.createTable(parent, tableId, table); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } + @Before + public void setUp() throws Exception { + adminClient = BigtableTableAdminClient + .create(InstanceName.of("[PROJECT]", "[INSTANCE]"), mockStub); + + Mockito.when(mockStub.createTableCallable()).thenReturn(mockCreateTableCallable); + Mockito.when(mockStub.modifyColumnFamiliesCallable()).thenReturn(mockModifyTableCallable); + Mockito.when(mockStub.deleteTableCallable()).thenReturn(mockDeleteTableCallable); + Mockito.when(mockStub.getTableCallable()).thenReturn(mockGetTableCallable); + Mockito.when(mockStub.listTablesCallable()).thenReturn(mockListTableCallable); + Mockito.when(mockStub.dropRowRangeCallable()).thenReturn(mockDropRowRangeCallable); + Mockito.when(mockStub.generateConsistencyTokenCallable()) + .thenReturn(mockGenerateConsistencyTokenCallable); + Mockito.when(mockStub.checkConsistencyCallable()).thenReturn(mockCheckConsistencyCallable); - @Test - @SuppressWarnings("all") - public void createTableFromSnapshotTest() throws Exception { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - Table expectedResponse = Table.newBuilder().setName(name.toString()).build(); - Operation resultOperation = - Operation.newBuilder() - .setName("createTableFromSnapshotTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) - .build(); - mockBigtableTableAdmin.addResponse(resultOperation); - - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String tableId = "tableId-895419604"; - SnapshotName sourceSnapshot = - SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - Table actualResponse = - client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get(); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateTableFromSnapshotRequest actualRequest = - (CreateTableFromSnapshotRequest) actualRequests.get(0); - - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertEquals(tableId, actualRequest.getTableId()); - Assert.assertEquals(sourceSnapshot, SnapshotName.parse(actualRequest.getSourceSnapshot())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + Table table = Table.newBuilder().build(); + ApiFuture
futureTable = ApiFutures.immediateFuture(table); + Mockito.when(mockCreateTableCallable.call(any(CreateTableRequest.class))).thenReturn(table); + Mockito.when(mockCreateTableCallable.futureCall(any(CreateTableRequest.class))) + .thenReturn(futureTable); + Mockito.when(mockModifyTableCallable.call(any(ModifyColumnFamiliesRequest.class))) + .thenReturn(table); + Mockito.when(mockModifyTableCallable.futureCall(any(ModifyColumnFamiliesRequest.class))) + .thenReturn(futureTable); + Mockito.when(mockGetTableCallable.call(any(GetTableRequest.class))).thenReturn(table); + Mockito.when(mockGetTableCallable.futureCall(any(GetTableRequest.class))) + .thenReturn(futureTable); } @Test - @SuppressWarnings("all") - public void createTableFromSnapshotExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - String tableId = "tableId-895419604"; - SnapshotName sourceSnapshot = - SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get(); - Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } + public void close() throws Exception { + adminClient.close(); + Mockito.verify(mockStub).close(); } @Test - @SuppressWarnings("all") - public void listTablesTest() { - String nextPageToken = ""; - Table tablesElement = Table.newBuilder().build(); - List
tables = Arrays.asList(tablesElement); - ListTablesResponse expectedResponse = - ListTablesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllTables(tables) - .build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - - ListTablesPagedResponse pagedListResponse = client.listTables(parent); - - List
resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getTablesList().get(0), resources.get(0)); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListTablesRequest actualRequest = (ListTablesRequest) actualRequests.get(0); - - Assert.assertEquals(parent, InstanceName.parse(actualRequest.getParent())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void createTable() { + CreateTable createTableReq = TableAdminRequests.createTable("tableId"); + adminClient.createTable(createTableReq); + Mockito.verify(mockCreateTableCallable) + .call(createTableReq.toProto(adminClient.getInstanceName())); } @Test - @SuppressWarnings("all") - public void listTablesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]"); - - client.listTables(parent); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void createTableAsync() { + CreateTable createTableReq = TableAdminRequests.createTable("tableId"); + adminClient.createTableAsync(createTableReq); + Mockito.verify(mockCreateTableCallable) + .futureCall(createTableReq.toProto(adminClient.getInstanceName())); } @Test - @SuppressWarnings("all") - public void getTableTest() { - TableName name2 = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - Table expectedResponse = Table.newBuilder().setName(name2.toString()).build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - Table actualResponse = client.getTable(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetTableRequest actualRequest = (GetTableRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void modifyFamilies() { + ModifyFamilies modifyFamReq = TableAdminRequests.modifyFamilies("tableId"); + adminClient.modifyFamilies(modifyFamReq); + Mockito.verify(mockModifyTableCallable) + .call(modifyFamReq.toProto(adminClient.getInstanceName())); } @Test - @SuppressWarnings("all") - public void getTableExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - client.getTable(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void modifyFamiliesAsync() { + ModifyFamilies modifyFamReq = TableAdminRequests.modifyFamilies("tableId"); + adminClient.modifyFamiliesAsync(modifyFamReq); + Mockito.verify(mockModifyTableCallable) + .futureCall(modifyFamReq.toProto(adminClient.getInstanceName())); } @Test - @SuppressWarnings("all") - public void deleteTableTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - client.deleteTable(name); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteTableRequest actualRequest = (DeleteTableRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void deleteTable() { + adminClient.deleteTable("tableId"); + Mockito.verify(mockDeleteTableCallable).call(adminClient.composeDeleteTableRequest("tableId")); } @Test - @SuppressWarnings("all") - public void deleteTableExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - client.deleteTable(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void deleteTableAsync() { + ApiFuture empty = ApiFutures.immediateFuture(Empty.newBuilder().build()); + Mockito.when(mockDeleteTableCallable.futureCall(any(DeleteTableRequest.class))) + .thenReturn(empty); + + adminClient.deleteTableAsync("tableId"); + Mockito.verify(mockDeleteTableCallable) + .futureCall(adminClient.composeDeleteTableRequest("tableId")); } @Test - @SuppressWarnings("all") - public void modifyColumnFamiliesTest() { - TableName name2 = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - Table expectedResponse = Table.newBuilder().setName(name2.toString()).build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - List modifications = new ArrayList<>(); - - Table actualResponse = client.modifyColumnFamilies(name, modifications); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ModifyColumnFamiliesRequest actualRequest = (ModifyColumnFamiliesRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertEquals(modifications, actualRequest.getModificationsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void getTable() { + adminClient.getTable("tableId"); + Mockito.verify(mockGetTableCallable).call(adminClient.composeGetTableRequest("tableId")); } @Test - @SuppressWarnings("all") - public void modifyColumnFamiliesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - List modifications = new ArrayList<>(); - - client.modifyColumnFamilies(name, modifications); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void getTableAsync() { + adminClient.getTableAsync("tableId"); + Mockito.verify(mockGetTableCallable).futureCall(adminClient.composeGetTableRequest("tableId")); } @Test - @SuppressWarnings("all") - public void generateConsistencyTokenTest() { - String consistencyToken = "consistencyToken-1090516718"; - GenerateConsistencyTokenResponse expectedResponse = - GenerateConsistencyTokenResponse.newBuilder().setConsistencyToken(consistencyToken).build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - GenerateConsistencyTokenResponse actualResponse = client.generateConsistencyToken(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GenerateConsistencyTokenRequest actualRequest = - (GenerateConsistencyTokenRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } + public void listTables() { + ListTablesResponse listTablesResponse = ListTablesResponse.newBuilder().build(); + Mockito.when(mockListTableCallable.call(adminClient.composeListTableRequest())) + .thenReturn(listTablesResponse); - @Test - @SuppressWarnings("all") - public void generateConsistencyTokenExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - - client.generateConsistencyToken(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + adminClient.listTables(); + Mockito.verify(mockListTableCallable).call(adminClient.composeListTableRequest()); } @Test - @SuppressWarnings("all") - public void checkConsistencyTest() { - boolean consistent = true; - CheckConsistencyResponse expectedResponse = - CheckConsistencyResponse.newBuilder().setConsistent(consistent).build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - String consistencyToken = "consistencyToken-1090516718"; - - CheckConsistencyResponse actualResponse = client.checkConsistency(name, consistencyToken); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CheckConsistencyRequest actualRequest = (CheckConsistencyRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertEquals(consistencyToken, actualRequest.getConsistencyToken()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void listTablesAsync() { + ApiFuture listTablesResponse = + ApiFutures.immediateFuture(ListTablesResponse.newBuilder().build()); + Mockito.when(mockListTableCallable.futureCall(adminClient.composeListTableRequest())) + .thenReturn(listTablesResponse); + + adminClient.listTablesAsync(); + Mockito.verify(mockListTableCallable).futureCall(adminClient.composeListTableRequest()); } @Test - @SuppressWarnings("all") - public void checkConsistencyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - String consistencyToken = "consistencyToken-1090516718"; - - client.checkConsistency(name, consistencyToken); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void dropRowRange() { + adminClient.dropRowRange("tableId", "rowKeyPrefix"); + Mockito.verify(mockDropRowRangeCallable) + .call( + adminClient.composeDropRowRangeRequest( + "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false)); } @Test - @SuppressWarnings("all") - public void snapshotTableTest() throws Exception { - SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - long dataSizeBytes = 2110122398L; - String description2 = "description2568623279"; - Snapshot expectedResponse = - Snapshot.newBuilder() - .setName(name2.toString()) - .setDataSizeBytes(dataSizeBytes) - .setDescription(description2) - .build(); - Operation resultOperation = - Operation.newBuilder() - .setName("snapshotTableTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) + public void getDropRowRangeRequest() { + DropRowRangeRequest actual = + adminClient.composeDropRowRangeRequest( + "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false); + + DropRowRangeRequest expected = + DropRowRangeRequest.newBuilder() + .setName(adminClient.getTableName("tableId")) + .setRowKeyPrefix(ByteString.copyFromUtf8("rowKeyPrefix")) .build(); - mockBigtableTableAdmin.addResponse(resultOperation); - - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); - SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - String description = "description-1724546052"; - - Snapshot actualResponse = - client.snapshotTableAsync(name, cluster, snapshotId, description).get(); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SnapshotTableRequest actualRequest = (SnapshotTableRequest) actualRequests.get(0); - - Assert.assertEquals(name, TableName.parse(actualRequest.getName())); - Assert.assertEquals(cluster, ClusterName.parse(actualRequest.getCluster())); - Assert.assertEquals(snapshotId, SnapshotName.parse(actualRequest.getSnapshotId())); - Assert.assertEquals(description, actualRequest.getDescription()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - @Test - @SuppressWarnings("all") - public void snapshotTableExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); - SnapshotName snapshotId = - SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - String description = "description-1724546052"; - - client.snapshotTableAsync(name, cluster, snapshotId, description).get(); - Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } + assertThat(actual).isEqualTo(expected); } @Test - @SuppressWarnings("all") - public void getSnapshotTest() { - SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - long dataSizeBytes = 2110122398L; - String description = "description-1724546052"; - Snapshot expectedResponse = - Snapshot.newBuilder() - .setName(name2.toString()) - .setDataSizeBytes(dataSizeBytes) - .setDescription(description) - .build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - Snapshot actualResponse = client.getSnapshot(name); - Assert.assertEquals(expectedResponse, actualResponse); + public void getDropRowRangeRequestDropAllData() { + DropRowRangeRequest actual = adminClient.composeDropRowRangeRequest("tableId", null, true); - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetSnapshotRequest actualRequest = (GetSnapshotRequest) actualRequests.get(0); + DropRowRangeRequest expected = + DropRowRangeRequest.newBuilder() + .setName(adminClient.getTableName("tableId")) + .setDeleteAllDataFromTable(true) + .build(); - Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + assertThat(actual).isEqualTo(expected); } @Test - @SuppressWarnings("all") - public void getSnapshotExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - client.getSnapshot(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void dropRowRangeAsync() { + ApiFuture empty = ApiFutures.immediateFuture(Empty.newBuilder().build()); + Mockito.when(mockDropRowRangeCallable.futureCall(any(DropRowRangeRequest.class))) + .thenReturn(empty); + + adminClient.dropRowRangeAsync("tableId", "rowKeyPrefix"); + Mockito.verify(mockDropRowRangeCallable) + .futureCall( + adminClient.composeDropRowRangeRequest( + "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false)); } @Test - @SuppressWarnings("all") - public void listSnapshotsTest() { - String nextPageToken = ""; - Snapshot snapshotsElement = Snapshot.newBuilder().build(); - List snapshots = Arrays.asList(snapshotsElement); - ListSnapshotsResponse expectedResponse = - ListSnapshotsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllSnapshots(snapshots) - .build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); - - ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(parent); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListSnapshotsRequest actualRequest = (ListSnapshotsRequest) actualRequests.get(0); - - Assert.assertEquals(parent, ClusterName.parse(actualRequest.getParent())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + public void generateAndCheckConsistency() { + GenerateConsistencyTokenResponse genResp = + GenerateConsistencyTokenResponse.newBuilder().build(); + Mockito.when( + mockGenerateConsistencyTokenCallable.call( + adminClient.composeGenerateConsistencyTokenRequest("tableId"))) + .thenReturn(genResp); + + ConsistencyToken consistencyToken = adminClient.generateConsistencyToken("tableId"); + Mockito.verify(mockGenerateConsistencyTokenCallable) + .call(adminClient.composeGenerateConsistencyTokenRequest("tableId")); + + ArgumentCaptor requestCaptor = + ArgumentCaptor.forClass(CheckConsistencyRequest.class); + CheckConsistencyResponse consistencyResp = CheckConsistencyResponse.newBuilder().build(); + Mockito.when(mockCheckConsistencyCallable.call(any(CheckConsistencyRequest.class))) + .thenReturn(consistencyResp); + + adminClient.isConsistent("tableId", consistencyToken); + Mockito.verify(mockCheckConsistencyCallable).call(requestCaptor.capture()); } @Test - @SuppressWarnings("all") - public void listSnapshotsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]"); - - client.listSnapshots(parent); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + public void generateAndCheckConsistencyAsync() throws Exception { + ApiFuture genResp = + ApiFutures.immediateFuture(GenerateConsistencyTokenResponse.newBuilder().build()); + Mockito.when( + mockGenerateConsistencyTokenCallable.futureCall( + adminClient.composeGenerateConsistencyTokenRequest("tableId"))) + .thenReturn(genResp); + + ApiFuture consistencyTokenFuture = + adminClient.generateConsistencyTokenAsync("tableId"); + Mockito.verify(mockGenerateConsistencyTokenCallable) + .futureCall(adminClient.composeGenerateConsistencyTokenRequest("tableId")); + + ArgumentCaptor requestCaptor = + ArgumentCaptor.forClass(CheckConsistencyRequest.class); + ApiFuture consistencyResp = + ApiFutures.immediateFuture(CheckConsistencyResponse.newBuilder().build()); + Mockito.when(mockCheckConsistencyCallable.futureCall(any(CheckConsistencyRequest.class))) + .thenReturn(consistencyResp); + + adminClient.isConsistentAsync("tableId", consistencyTokenFuture.get()); + Mockito.verify(mockCheckConsistencyCallable).futureCall(requestCaptor.capture()); } @Test - @SuppressWarnings("all") - public void deleteSnapshotTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockBigtableTableAdmin.addResponse(expectedResponse); - - SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - client.deleteSnapshot(name); - - List actualRequests = mockBigtableTableAdmin.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteSnapshotRequest actualRequest = (DeleteSnapshotRequest) actualRequests.get(0); + public void convertToTableNames() { + ListTablesResponse listTablesResponse = + ListTablesResponse.newBuilder() + .addTables(Table.newBuilder().setName("projects/p/instances/i/tables/t1")) + .addTables(Table.newBuilder().setName("projects/p/instances/i/tables/t2")) + .build(); - Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } + List tableNames = BigtableTableAdminClient.convertToTableNames(listTablesResponse); + assertEquals(2, tableNames.size()); + assertEquals("projects/p/instances/i/tables/t1", tableNames.get(0).toString()); + assertEquals("projects/p/instances/i/tables/t2", tableNames.get(1).toString()); - @Test - @SuppressWarnings("all") - public void deleteSnapshotExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtableTableAdmin.addException(exception); - - try { - SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); - - client.deleteSnapshot(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + listTablesResponse = ListTablesResponse.newBuilder().build(); + assertEquals(0, BigtableTableAdminClient.convertToTableNames(listTablesResponse).size()); } } diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminSettingsTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java similarity index 88% rename from google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminSettingsTest.java rename to google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java index 8bf706cf8228..447c86fdc309 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminSettingsTest.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java @@ -22,13 +22,13 @@ import java.io.IOException; import org.junit.Test; -public class TableAdminSettingsTest { +public class BigtableTableAdminSettingsTest { @Test public void testInstanceName() throws IOException { InstanceName instanceName = InstanceName.of("my-project", "my-instance"); - TableAdminSettings.Builder builder = TableAdminSettings.newBuilder() + BigtableTableAdminSettings.Builder builder = BigtableTableAdminSettings.newBuilder() .setInstanceName(instanceName); assertThat(builder.getInstanceName()).isEqualTo(instanceName); @@ -41,7 +41,7 @@ public void testMissingInstanceName() { Exception actualException = null; try { - TableAdminSettings.newBuilder().build(); + BigtableTableAdminSettings.newBuilder().build(); } catch (Exception e) { actualException = e; } @@ -53,7 +53,7 @@ public void testMissingInstanceName() { public void testStubSettings() throws IOException { InstanceName instanceName = InstanceName.of("my-project", "my-instance"); - TableAdminSettings.Builder builder = TableAdminSettings.newBuilder() + BigtableTableAdminSettings.Builder builder = BigtableTableAdminSettings.newBuilder() .setInstanceName(instanceName); builder.stubSettings().createTableSettings() diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java deleted file mode 100644 index 0c0b60b8f2dd..000000000000 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/TableAdminClientTest.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigtable.admin.v2; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.bigtable.admin.v2.CheckConsistencyRequest; -import com.google.bigtable.admin.v2.CheckConsistencyResponse; -import com.google.bigtable.admin.v2.CreateTableRequest; -import com.google.bigtable.admin.v2.DeleteTableRequest; -import com.google.bigtable.admin.v2.DropRowRangeRequest; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest; -import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse; -import com.google.bigtable.admin.v2.GetTableRequest; -import com.google.bigtable.admin.v2.InstanceName; -import com.google.bigtable.admin.v2.ListTablesRequest; -import com.google.bigtable.admin.v2.ListTablesResponse; -import com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest; -import com.google.bigtable.admin.v2.Table; -import com.google.bigtable.admin.v2.TableName; -import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests; -import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.CreateTable; -import com.google.cloud.bigtable.admin.v2.models.TableAdminRequests.ModifyFamilies; -import com.google.cloud.bigtable.admin.v2.models.TableAdminResponses.ConsistencyToken; -import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; -import com.google.protobuf.ByteString; -import com.google.protobuf.Empty; - -@RunWith(MockitoJUnitRunner.class) -public class TableAdminClientTest { - private TableAdminClient adminClient; - @Mock private BigtableTableAdminStub mockStub; - - @Mock private UnaryCallable mockCreateTableCallable; - @Mock private UnaryCallable mockModifyTableCallable; - @Mock private UnaryCallable mockDeleteTableCallable; - @Mock private UnaryCallable mockGetTableCallable; - @Mock private UnaryCallable mockListTableCallable; - @Mock private UnaryCallable mockDropRowRangeCallable; - - @Mock - private UnaryCallable - mockGenerateConsistencyTokenCallable; - - @Mock - private UnaryCallable - mockCheckConsistencyCallable; - - @Before - public void setUp() throws Exception { - adminClient = TableAdminClient.create(InstanceName.of("[PROJECT]", "[INSTANCE]"), mockStub); - - Mockito.when(mockStub.createTableCallable()).thenReturn(mockCreateTableCallable); - Mockito.when(mockStub.modifyColumnFamiliesCallable()).thenReturn(mockModifyTableCallable); - Mockito.when(mockStub.deleteTableCallable()).thenReturn(mockDeleteTableCallable); - Mockito.when(mockStub.getTableCallable()).thenReturn(mockGetTableCallable); - Mockito.when(mockStub.listTablesCallable()).thenReturn(mockListTableCallable); - Mockito.when(mockStub.dropRowRangeCallable()).thenReturn(mockDropRowRangeCallable); - Mockito.when(mockStub.generateConsistencyTokenCallable()) - .thenReturn(mockGenerateConsistencyTokenCallable); - Mockito.when(mockStub.checkConsistencyCallable()).thenReturn(mockCheckConsistencyCallable); - - Table table = Table.newBuilder().build(); - ApiFuture
futureTable = ApiFutures.immediateFuture(table); - Mockito.when(mockCreateTableCallable.call(any(CreateTableRequest.class))).thenReturn(table); - Mockito.when(mockCreateTableCallable.futureCall(any(CreateTableRequest.class))) - .thenReturn(futureTable); - Mockito.when(mockModifyTableCallable.call(any(ModifyColumnFamiliesRequest.class))) - .thenReturn(table); - Mockito.when(mockModifyTableCallable.futureCall(any(ModifyColumnFamiliesRequest.class))) - .thenReturn(futureTable); - Mockito.when(mockGetTableCallable.call(any(GetTableRequest.class))).thenReturn(table); - Mockito.when(mockGetTableCallable.futureCall(any(GetTableRequest.class))) - .thenReturn(futureTable); - } - - @Test - public void close() throws Exception { - adminClient.close(); - Mockito.verify(mockStub).close(); - } - - @Test - public void createTable() { - CreateTable createTableReq = TableAdminRequests.createTable("tableId"); - adminClient.createTable(createTableReq); - Mockito.verify(mockCreateTableCallable) - .call(createTableReq.toProto(adminClient.getInstanceName())); - } - - @Test - public void createTableAsync() { - CreateTable createTableReq = TableAdminRequests.createTable("tableId"); - adminClient.createTableAsync(createTableReq); - Mockito.verify(mockCreateTableCallable) - .futureCall(createTableReq.toProto(adminClient.getInstanceName())); - } - - @Test - public void modifyFamilies() { - ModifyFamilies modifyFamReq = TableAdminRequests.modifyFamilies("tableId"); - adminClient.modifyFamilies(modifyFamReq); - Mockito.verify(mockModifyTableCallable) - .call(modifyFamReq.toProto(adminClient.getInstanceName())); - } - - @Test - public void modifyFamiliesAsync() { - ModifyFamilies modifyFamReq = TableAdminRequests.modifyFamilies("tableId"); - adminClient.modifyFamiliesAsync(modifyFamReq); - Mockito.verify(mockModifyTableCallable) - .futureCall(modifyFamReq.toProto(adminClient.getInstanceName())); - } - - @Test - public void deleteTable() { - adminClient.deleteTable("tableId"); - Mockito.verify(mockDeleteTableCallable).call(adminClient.composeDeleteTableRequest("tableId")); - } - - @Test - public void deleteTableAsync() { - ApiFuture empty = ApiFutures.immediateFuture(Empty.newBuilder().build()); - Mockito.when(mockDeleteTableCallable.futureCall(any(DeleteTableRequest.class))) - .thenReturn(empty); - - adminClient.deleteTableAsync("tableId"); - Mockito.verify(mockDeleteTableCallable) - .futureCall(adminClient.composeDeleteTableRequest("tableId")); - } - - @Test - public void getTable() { - adminClient.getTable("tableId"); - Mockito.verify(mockGetTableCallable).call(adminClient.composeGetTableRequest("tableId")); - } - - @Test - public void getTableAsync() { - adminClient.getTableAsync("tableId"); - Mockito.verify(mockGetTableCallable).futureCall(adminClient.composeGetTableRequest("tableId")); - } - - @Test - public void listTables() { - ListTablesResponse listTablesResponse = ListTablesResponse.newBuilder().build(); - Mockito.when(mockListTableCallable.call(adminClient.composeListTableRequest())) - .thenReturn(listTablesResponse); - - adminClient.listTables(); - Mockito.verify(mockListTableCallable).call(adminClient.composeListTableRequest()); - } - - @Test - public void listTablesAsync() { - ApiFuture listTablesResponse = - ApiFutures.immediateFuture(ListTablesResponse.newBuilder().build()); - Mockito.when(mockListTableCallable.futureCall(adminClient.composeListTableRequest())) - .thenReturn(listTablesResponse); - - adminClient.listTablesAsync(); - Mockito.verify(mockListTableCallable).futureCall(adminClient.composeListTableRequest()); - } - - @Test - public void dropRowRange() { - adminClient.dropRowRange("tableId", "rowKeyPrefix"); - Mockito.verify(mockDropRowRangeCallable) - .call( - adminClient.composeDropRowRangeRequest( - "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false)); - } - - @Test - public void getDropRowRangeRequest() { - DropRowRangeRequest actual = - adminClient.composeDropRowRangeRequest( - "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false); - - DropRowRangeRequest expected = - DropRowRangeRequest.newBuilder() - .setName(adminClient.getTableName("tableId")) - .setRowKeyPrefix(ByteString.copyFromUtf8("rowKeyPrefix")) - .build(); - - assertThat(actual).isEqualTo(expected); - } - - @Test - public void getDropRowRangeRequestDropAllData() { - DropRowRangeRequest actual = adminClient.composeDropRowRangeRequest("tableId", null, true); - - DropRowRangeRequest expected = - DropRowRangeRequest.newBuilder() - .setName(adminClient.getTableName("tableId")) - .setDeleteAllDataFromTable(true) - .build(); - - assertThat(actual).isEqualTo(expected); - } - - @Test - public void dropRowRangeAsync() { - ApiFuture empty = ApiFutures.immediateFuture(Empty.newBuilder().build()); - Mockito.when(mockDropRowRangeCallable.futureCall(any(DropRowRangeRequest.class))) - .thenReturn(empty); - - adminClient.dropRowRangeAsync("tableId", "rowKeyPrefix"); - Mockito.verify(mockDropRowRangeCallable) - .futureCall( - adminClient.composeDropRowRangeRequest( - "tableId", ByteString.copyFromUtf8("rowKeyPrefix"), false)); - } - - @Test - public void generateAndCheckConsistency() { - GenerateConsistencyTokenResponse genResp = - GenerateConsistencyTokenResponse.newBuilder().build(); - Mockito.when( - mockGenerateConsistencyTokenCallable.call( - adminClient.composeGenerateConsistencyTokenRequest("tableId"))) - .thenReturn(genResp); - - ConsistencyToken consistencyToken = adminClient.generateConsistencyToken("tableId"); - Mockito.verify(mockGenerateConsistencyTokenCallable) - .call(adminClient.composeGenerateConsistencyTokenRequest("tableId")); - - ArgumentCaptor requestCaptor = - ArgumentCaptor.forClass(CheckConsistencyRequest.class); - CheckConsistencyResponse consistencyResp = CheckConsistencyResponse.newBuilder().build(); - Mockito.when(mockCheckConsistencyCallable.call(any(CheckConsistencyRequest.class))) - .thenReturn(consistencyResp); - - adminClient.isConsistent("tableId", consistencyToken); - Mockito.verify(mockCheckConsistencyCallable).call(requestCaptor.capture()); - } - - @Test - public void generateAndCheckConsistencyAsync() throws Exception { - ApiFuture genResp = - ApiFutures.immediateFuture(GenerateConsistencyTokenResponse.newBuilder().build()); - Mockito.when( - mockGenerateConsistencyTokenCallable.futureCall( - adminClient.composeGenerateConsistencyTokenRequest("tableId"))) - .thenReturn(genResp); - - ApiFuture consistencyTokenFuture = - adminClient.generateConsistencyTokenAsync("tableId"); - Mockito.verify(mockGenerateConsistencyTokenCallable) - .futureCall(adminClient.composeGenerateConsistencyTokenRequest("tableId")); - - ArgumentCaptor requestCaptor = - ArgumentCaptor.forClass(CheckConsistencyRequest.class); - ApiFuture consistencyResp = - ApiFutures.immediateFuture(CheckConsistencyResponse.newBuilder().build()); - Mockito.when(mockCheckConsistencyCallable.futureCall(any(CheckConsistencyRequest.class))) - .thenReturn(consistencyResp); - - adminClient.isConsistentAsync("tableId", consistencyTokenFuture.get()); - Mockito.verify(mockCheckConsistencyCallable).futureCall(requestCaptor.capture()); - } - - @Test - public void convertToTableNames() { - ListTablesResponse listTablesResponse = - ListTablesResponse.newBuilder() - .addTables(Table.newBuilder().setName("projects/p/instances/i/tables/t1")) - .addTables(Table.newBuilder().setName("projects/p/instances/i/tables/t2")) - .build(); - - List tableNames = TableAdminClient.convertToTableNames(listTablesResponse); - assertEquals(2, tableNames.size()); - assertEquals("projects/p/instances/i/tables/t1", tableNames.get(0).toString()); - assertEquals("projects/p/instances/i/tables/t2", tableNames.get(1).toString()); - - listTablesResponse = ListTablesResponse.newBuilder().build(); - assertEquals(0, TableAdminClient.convertToTableNames(listTablesResponse).size()); - } -} diff --git a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java similarity index 97% rename from google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java rename to google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java index 33195f282062..d4805ed51eb3 100644 --- a/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/TableAdminClientIT.java +++ b/google-cloud-clients/google-cloud-bigtable-admin/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java @@ -23,7 +23,7 @@ import com.google.bigtable.admin.v2.InstanceName; import com.google.bigtable.admin.v2.TableName; -import com.google.cloud.bigtable.admin.v2.TableAdminClient; +import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient; import com.google.cloud.bigtable.admin.v2.models.GCRules.DurationRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.IntersectionRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.UnionRule; @@ -43,10 +43,10 @@ import org.junit.Test; import org.threeten.bp.Duration; -public class TableAdminClientIT { +public class BigtableTableAdminClientIT { private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance"; - private static TableAdminClient tableAdmin; + private static BigtableTableAdminClient tableAdmin; @BeforeClass public static void createClient() throws IOException { @@ -58,7 +58,7 @@ public static void createClient() throws IOException { } InstanceName instanceName = InstanceName.parse(targetInstance); - tableAdmin = TableAdminClient.create(instanceName); + tableAdmin = BigtableTableAdminClient.create(instanceName); } @AfterClass