diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java index 17868a28b00d..29c071eb3836 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; @@ -75,76 +76,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * 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. - * - *

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 (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
- *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
- *   Instance response = baseBigtableInstanceAdminClient.getInstance(name);
- * }
- * 
- * 
- * - *

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

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

To customize credentials: - * - *

- * 
- * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings =
- *     BaseBigtableInstanceAdminSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
- *     BaseBigtableInstanceAdminClient.create(baseBigtableInstanceAdminSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings =
- *     BaseBigtableInstanceAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
- *     BaseBigtableInstanceAdminClient.create(baseBigtableInstanceAdminSettings);
- * 
- * 
- */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi +@InternalApi public class BaseBigtableInstanceAdminClient implements BackgroundResource { private final BaseBigtableInstanceAdminSettings settings; private final BigtableInstanceAdminStub stub; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java index 0b8f4025d53a..1a917e098983 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; @@ -67,33 +68,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link BaseBigtableInstanceAdminClient}. - * - *

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

- * - *

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 getInstance to 30 seconds: - * - *

- * 
- * BaseBigtableInstanceAdminSettings.Builder baseBigtableInstanceAdminSettingsBuilder =
- *     BaseBigtableInstanceAdminSettings.newBuilder();
- * baseBigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings = baseBigtableInstanceAdminSettingsBuilder.build();
- * 
- * 
- */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi +@InternalApi public class BaseBigtableInstanceAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createInstance. */ diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java index 6b49ff4ecc38..8a7f6b18a0c3 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; @@ -64,78 +65,9 @@ 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);
- * 
- * 
- */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi +@InternalApi public class BaseBigtableTableAdminClient implements BackgroundResource { private final BaseBigtableTableAdminSettings settings; private final BigtableTableAdminStub stub; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java index 3ce390b3e554..c3fa3a40d80a 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; @@ -59,33 +60,9 @@ 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 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();
- * 
- * 
- */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi +@InternalApi public class BaseBigtableTableAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createTable. */ public UnaryCallSettings createTableSettings() { diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java index 4b3b5360e474..e6b8340c68ac 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java @@ -15,45 +15,11 @@ */ /** - * A client to Cloud Bigtable Admin API. + * Clients for the Cloud Bigtable admin API. * - *

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

These APIs allow callers to create and manage Cloud Bigtable resources. * - *

=============================== 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 BaseBigtableInstanceAdminClient: - * - *

- * 
- * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient = BaseBigtableInstanceAdminClient.create()) {
- *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
- *   Instance response = baseBigtableInstanceAdminClient.getInstance(name);
- * }
- * 
- * 
- * - * ============================ 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 BaseBigtableTableAdminClient: - * - *

- * 
- * 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);
- * }
- * 
- * 
+ * @see com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient for instance level API. + * @see com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient for table level API. */ package com.google.cloud.bigtable.admin.v2; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java index a394891f96ba..264af82f3c4a 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java @@ -18,6 +18,7 @@ import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -57,13 +58,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Cloud Bigtable Admin API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public abstract class BigtableInstanceAdminStub implements BackgroundResource { @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java index 463589fb4e32..8a4354273184 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java @@ -19,6 +19,7 @@ import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -49,13 +50,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Cloud Bigtable Admin API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public abstract class BigtableTableAdminStub implements BackgroundResource { @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java index 025403e7a437..76ffdc7bde63 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java @@ -16,6 +16,7 @@ package com.google.cloud.bigtable.admin.v2.stub; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -35,13 +36,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +@InternalApi public class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java index ced9014618d3..2ce6633ec0cc 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java @@ -18,6 +18,7 @@ import static com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -68,13 +69,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { private static final MethodDescriptor diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java index dca920650a46..a1ed5e5dc82c 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java @@ -16,6 +16,7 @@ package com.google.cloud.bigtable.admin.v2.stub; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -35,13 +36,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +@InternalApi public class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java index 233e37e7cc80..0ee55693503e 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java @@ -19,6 +19,7 @@ import static com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListTablesPagedResponse; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -60,13 +61,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { private static final MethodDescriptor createTableMethodDescriptor = diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java deleted file mode 100644 index ea657d44ea5d..000000000000 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright 2019 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.data.v2; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.bigtable.v2.CheckAndMutateRowRequest; -import com.google.bigtable.v2.CheckAndMutateRowResponse; -import com.google.bigtable.v2.MutateRowRequest; -import com.google.bigtable.v2.MutateRowResponse; -import com.google.bigtable.v2.MutateRowsRequest; -import com.google.bigtable.v2.MutateRowsResponse; -import com.google.bigtable.v2.Mutation; -import com.google.bigtable.v2.ReadModifyWriteRowRequest; -import com.google.bigtable.v2.ReadModifyWriteRowResponse; -import com.google.bigtable.v2.ReadModifyWriteRule; -import com.google.bigtable.v2.ReadRowsRequest; -import com.google.bigtable.v2.ReadRowsResponse; -import com.google.bigtable.v2.RowFilter; -import com.google.bigtable.v2.SampleRowKeysRequest; -import com.google.bigtable.v2.SampleRowKeysResponse; -import com.google.bigtable.v2.TableName; -import com.google.cloud.bigtable.data.v2.stub.BigtableStub; -import com.google.cloud.bigtable.data.v2.stub.BigtableStubSettings; -import com.google.protobuf.ByteString; -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 reading from and writing to existing Bigtable 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 (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
- *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
- *   ByteString rowKey = ByteString.copyFromUtf8("");
- *   List<Mutation> mutations = new ArrayList<>();
- *   MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName, rowKey, mutations);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the baseBigtableDataClient 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 BaseBigtableDataSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * BaseBigtableDataSettings baseBigtableDataSettings =
- *     BaseBigtableDataSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * BaseBigtableDataClient baseBigtableDataClient =
- *     BaseBigtableDataClient.create(baseBigtableDataSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * BaseBigtableDataSettings baseBigtableDataSettings =
- *     BaseBigtableDataSettings.newBuilder().setEndpoint(myEndpoint).build();
- * BaseBigtableDataClient baseBigtableDataClient =
- *     BaseBigtableDataClient.create(baseBigtableDataSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class BaseBigtableDataClient implements BackgroundResource { - private final BaseBigtableDataSettings settings; - private final BigtableStub stub; - - /** Constructs an instance of BaseBigtableDataClient with default settings. */ - public static final BaseBigtableDataClient create() throws IOException { - return create(BaseBigtableDataSettings.newBuilder().build()); - } - - /** - * Constructs an instance of BaseBigtableDataClient, 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 BaseBigtableDataClient create(BaseBigtableDataSettings settings) - throws IOException { - return new BaseBigtableDataClient(settings); - } - - /** - * Constructs an instance of BaseBigtableDataClient, using the given stub for making calls. This - * is for advanced usage - prefer to use BaseBigtableDataSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final BaseBigtableDataClient create(BigtableStub stub) { - return new BaseBigtableDataClient(stub); - } - - /** - * Constructs an instance of BaseBigtableDataClient, 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 BaseBigtableDataClient(BaseBigtableDataSettings settings) throws IOException { - this.settings = settings; - this.stub = ((BigtableStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected BaseBigtableDataClient(BigtableStub stub) { - this.settings = null; - this.stub = stub; - } - - public final BaseBigtableDataSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public BigtableStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Streams back the contents of all requested rows in key order, optionally applying the same - * Reader filter to each. Depending on their size, rows and cells may be broken up across multiple - * responses, but atomicity of each row will still be preserved. See the ReadRowsResponse - * documentation for details. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ReadRowsRequest request = ReadRowsRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .build();
-   *
-   *   ServerStream<ReadRowsResponse> stream = baseBigtableDataClient.readRowsCallable().call(request);
-   *   for (ReadRowsResponse response : stream) {
-   *     // Do something when receive a response
-   *   }
-   * }
-   * 
- */ - public final ServerStreamingCallable readRowsCallable() { - return stub.readRowsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a sample of row keys in the table. The returned row keys will delimit contiguous - * sections of the table of approximately equal size, which can be used to break up the data for - * distributed tasks like mapreduces. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   SampleRowKeysRequest request = SampleRowKeysRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .build();
-   *
-   *   ServerStream<SampleRowKeysResponse> stream = baseBigtableDataClient.sampleRowKeysCallable().call(request);
-   *   for (SampleRowKeysResponse response : stream) {
-   *     // Do something when receive a response
-   *   }
-   * }
-   * 
- */ - public final ServerStreamingCallable - sampleRowKeysCallable() { - return stub.sampleRowKeysCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly - * changed by `mutation`. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<Mutation> mutations = new ArrayList<>();
-   *   MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName, rowKey, mutations);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the mutation should be applied. Values - * are of the form `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the mutation should be applied. - * @param mutations Changes to be atomically applied to the specified row. Entries are applied in - * order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry and at most 100000. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MutateRowResponse mutateRow( - TableName tableName, ByteString rowKey, List mutations) { - - MutateRowRequest request = - MutateRowRequest.newBuilder() - .setTableName(tableName == null ? null : tableName.toString()) - .setRowKey(rowKey) - .addAllMutations(mutations) - .build(); - return mutateRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly - * changed by `mutation`. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<Mutation> mutations = new ArrayList<>();
-   *   MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName.toString(), rowKey, mutations);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the mutation should be applied. Values - * are of the form `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the mutation should be applied. - * @param mutations Changes to be atomically applied to the specified row. Entries are applied in - * order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry and at most 100000. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MutateRowResponse mutateRow( - String tableName, ByteString rowKey, List mutations) { - - MutateRowRequest request = - MutateRowRequest.newBuilder() - .setTableName(tableName) - .setRowKey(rowKey) - .addAllMutations(mutations) - .build(); - return mutateRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly - * changed by `mutation`. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<Mutation> mutations = new ArrayList<>();
-   *   MutateRowRequest request = MutateRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .addAllMutations(mutations)
-   *     .build();
-   *   MutateRowResponse response = baseBigtableDataClient.mutateRow(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 MutateRowResponse mutateRow(MutateRowRequest request) { - return mutateRowCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly - * changed by `mutation`. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<Mutation> mutations = new ArrayList<>();
-   *   MutateRowRequest request = MutateRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .addAllMutations(mutations)
-   *     .build();
-   *   ApiFuture<MutateRowResponse> future = baseBigtableDataClient.mutateRowCallable().futureCall(request);
-   *   // Do something
-   *   MutateRowResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable mutateRowCallable() { - return stub.mutateRowCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, - * but the entire batch is not executed atomically. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   List<MutateRowsRequest.Entry> entries = new ArrayList<>();
-   *   MutateRowsRequest request = MutateRowsRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .addAllEntries(entries)
-   *     .build();
-   *
-   *   ServerStream<MutateRowsResponse> stream = baseBigtableDataClient.mutateRowsCallable().call(request);
-   *   for (MutateRowsResponse response : stream) {
-   *     // Do something when receive a response
-   *   }
-   * }
-   * 
- */ - public final ServerStreamingCallable mutateRowsCallable() { - return stub.mutateRowsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   RowFilter predicateFilter = RowFilter.newBuilder().build();
-   *   List<Mutation> trueMutations = new ArrayList<>();
-   *   List<Mutation> falseMutations = new ArrayList<>();
-   *   CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the conditional mutation should be - * applied. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the conditional mutation should be applied. - * @param predicateFilter The filter to be applied to the contents of the specified row. Depending - * on whether or not any results are yielded, either `true_mutations` or `false_mutations` - * will be executed. If unset, checks that the row contains any values at all. - * @param trueMutations Changes to be atomically applied to the specified row if - * `predicate_filter` yields at least one cell when applied to `row_key`. Entries are applied - * in order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry if `false_mutations` is empty, and at most 100000. - * @param falseMutations Changes to be atomically applied to the specified row if - * `predicate_filter` does not yield any cells when applied to `row_key`. Entries are applied - * in order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry if `true_mutations` is empty, and at most 100000. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final CheckAndMutateRowResponse checkAndMutateRow( - TableName tableName, - ByteString rowKey, - RowFilter predicateFilter, - List trueMutations, - List falseMutations) { - - CheckAndMutateRowRequest request = - CheckAndMutateRowRequest.newBuilder() - .setTableName(tableName == null ? null : tableName.toString()) - .setRowKey(rowKey) - .setPredicateFilter(predicateFilter) - .addAllTrueMutations(trueMutations) - .addAllFalseMutations(falseMutations) - .build(); - return checkAndMutateRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   RowFilter predicateFilter = RowFilter.newBuilder().build();
-   *   List<Mutation> trueMutations = new ArrayList<>();
-   *   List<Mutation> falseMutations = new ArrayList<>();
-   *   CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(tableName.toString(), rowKey, predicateFilter, trueMutations, falseMutations);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the conditional mutation should be - * applied. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the conditional mutation should be applied. - * @param predicateFilter The filter to be applied to the contents of the specified row. Depending - * on whether or not any results are yielded, either `true_mutations` or `false_mutations` - * will be executed. If unset, checks that the row contains any values at all. - * @param trueMutations Changes to be atomically applied to the specified row if - * `predicate_filter` yields at least one cell when applied to `row_key`. Entries are applied - * in order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry if `false_mutations` is empty, and at most 100000. - * @param falseMutations Changes to be atomically applied to the specified row if - * `predicate_filter` does not yield any cells when applied to `row_key`. Entries are applied - * in order, meaning that earlier mutations can be masked by later ones. Must contain at least - * one entry if `true_mutations` is empty, and at most 100000. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final CheckAndMutateRowResponse checkAndMutateRow( - String tableName, - ByteString rowKey, - RowFilter predicateFilter, - List trueMutations, - List falseMutations) { - - CheckAndMutateRowRequest request = - CheckAndMutateRowRequest.newBuilder() - .setTableName(tableName) - .setRowKey(rowKey) - .setPredicateFilter(predicateFilter) - .addAllTrueMutations(trueMutations) - .addAllFalseMutations(falseMutations) - .build(); - return checkAndMutateRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .build();
-   *   CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(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 CheckAndMutateRowResponse checkAndMutateRow(CheckAndMutateRowRequest request) { - return checkAndMutateRowCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .build();
-   *   ApiFuture<CheckAndMutateRowResponse> future = baseBigtableDataClient.checkAndMutateRowCallable().futureCall(request);
-   *   // Do something
-   *   CheckAndMutateRowResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - checkAndMutateRowCallable() { - return stub.checkAndMutateRowCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Modifies a row atomically on the server. The method reads the latest existing timestamp and - * value from the specified columns and writes a new entry based on pre-defined read/modify/write - * rules. The new value for the timestamp is the greater of the existing timestamp or the current - * server time. The method returns the new contents of all modified cells. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<ReadModifyWriteRule> rules = new ArrayList<>();
-   *   ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(tableName, rowKey, rules);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the read/modify/write rules should be - * applied. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the read/modify/write rules should be applied. - * @param rules Rules specifying how the specified row's contents are to be transformed into - * writes. Entries are applied in order, meaning that earlier rules will affect the results of - * later ones. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ReadModifyWriteRowResponse readModifyWriteRow( - TableName tableName, ByteString rowKey, List rules) { - - ReadModifyWriteRowRequest request = - ReadModifyWriteRowRequest.newBuilder() - .setTableName(tableName == null ? null : tableName.toString()) - .setRowKey(rowKey) - .addAllRules(rules) - .build(); - return readModifyWriteRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Modifies a row atomically on the server. The method reads the latest existing timestamp and - * value from the specified columns and writes a new entry based on pre-defined read/modify/write - * rules. The new value for the timestamp is the greater of the existing timestamp or the current - * server time. The method returns the new contents of all modified cells. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<ReadModifyWriteRule> rules = new ArrayList<>();
-   *   ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(tableName.toString(), rowKey, rules);
-   * }
-   * 
- * - * @param tableName The unique name of the table to which the read/modify/write rules should be - * applied. Values are of the form - * `projects/<project>/instances/<instance>/tables/<table>`. - * @param rowKey The key of the row to which the read/modify/write rules should be applied. - * @param rules Rules specifying how the specified row's contents are to be transformed into - * writes. Entries are applied in order, meaning that earlier rules will affect the results of - * later ones. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ReadModifyWriteRowResponse readModifyWriteRow( - String tableName, ByteString rowKey, List rules) { - - ReadModifyWriteRowRequest request = - ReadModifyWriteRowRequest.newBuilder() - .setTableName(tableName) - .setRowKey(rowKey) - .addAllRules(rules) - .build(); - return readModifyWriteRow(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Modifies a row atomically on the server. The method reads the latest existing timestamp and - * value from the specified columns and writes a new entry based on pre-defined read/modify/write - * rules. The new value for the timestamp is the greater of the existing timestamp or the current - * server time. The method returns the new contents of all modified cells. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<ReadModifyWriteRule> rules = new ArrayList<>();
-   *   ReadModifyWriteRowRequest request = ReadModifyWriteRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .addAllRules(rules)
-   *     .build();
-   *   ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(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 ReadModifyWriteRowResponse readModifyWriteRow(ReadModifyWriteRowRequest request) { - return readModifyWriteRowCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Modifies a row atomically on the server. The method reads the latest existing timestamp and - * value from the specified columns and writes a new entry based on pre-defined read/modify/write - * rules. The new value for the timestamp is the greater of the existing timestamp or the current - * server time. The method returns the new contents of all modified cells. - * - *

Sample code: - * - *


-   * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
-   *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
-   *   ByteString rowKey = ByteString.copyFromUtf8("");
-   *   List<ReadModifyWriteRule> rules = new ArrayList<>();
-   *   ReadModifyWriteRowRequest request = ReadModifyWriteRowRequest.newBuilder()
-   *     .setTableName(tableName.toString())
-   *     .setRowKey(rowKey)
-   *     .addAllRules(rules)
-   *     .build();
-   *   ApiFuture<ReadModifyWriteRowResponse> future = baseBigtableDataClient.readModifyWriteRowCallable().futureCall(request);
-   *   // Do something
-   *   ReadModifyWriteRowResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - readModifyWriteRowCallable() { - return stub.readModifyWriteRowCallable(); - } - - @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); - } -} diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java deleted file mode 100644 index ae6339e1b385..000000000000 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2019 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.data.v2; - -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.ServerStreamingCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.bigtable.v2.CheckAndMutateRowRequest; -import com.google.bigtable.v2.CheckAndMutateRowResponse; -import com.google.bigtable.v2.MutateRowRequest; -import com.google.bigtable.v2.MutateRowResponse; -import com.google.bigtable.v2.MutateRowsRequest; -import com.google.bigtable.v2.MutateRowsResponse; -import com.google.bigtable.v2.ReadModifyWriteRowRequest; -import com.google.bigtable.v2.ReadModifyWriteRowResponse; -import com.google.bigtable.v2.ReadRowsRequest; -import com.google.bigtable.v2.ReadRowsResponse; -import com.google.bigtable.v2.SampleRowKeysRequest; -import com.google.bigtable.v2.SampleRowKeysResponse; -import com.google.cloud.bigtable.data.v2.stub.BigtableStubSettings; -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 BaseBigtableDataClient}. - * - *

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

    - *
  • The default service address (bigtable.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 mutateRow to 30 seconds: - * - *

- * 
- * BaseBigtableDataSettings.Builder baseBigtableDataSettingsBuilder =
- *     BaseBigtableDataSettings.newBuilder();
- * baseBigtableDataSettingsBuilder.mutateRowSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BaseBigtableDataSettings baseBigtableDataSettings = baseBigtableDataSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class BaseBigtableDataSettings extends ClientSettings { - /** Returns the object with the settings used for calls to readRows. */ - public ServerStreamingCallSettings readRowsSettings() { - return ((BigtableStubSettings) getStubSettings()).readRowsSettings(); - } - - /** Returns the object with the settings used for calls to sampleRowKeys. */ - public ServerStreamingCallSettings - sampleRowKeysSettings() { - return ((BigtableStubSettings) getStubSettings()).sampleRowKeysSettings(); - } - - /** Returns the object with the settings used for calls to mutateRow. */ - public UnaryCallSettings mutateRowSettings() { - return ((BigtableStubSettings) getStubSettings()).mutateRowSettings(); - } - - /** Returns the object with the settings used for calls to mutateRows. */ - public ServerStreamingCallSettings mutateRowsSettings() { - return ((BigtableStubSettings) getStubSettings()).mutateRowsSettings(); - } - - /** Returns the object with the settings used for calls to checkAndMutateRow. */ - public UnaryCallSettings - checkAndMutateRowSettings() { - return ((BigtableStubSettings) getStubSettings()).checkAndMutateRowSettings(); - } - - /** Returns the object with the settings used for calls to readModifyWriteRow. */ - public UnaryCallSettings - readModifyWriteRowSettings() { - return ((BigtableStubSettings) getStubSettings()).readModifyWriteRowSettings(); - } - - public static final BaseBigtableDataSettings create(BigtableStubSettings stub) - throws IOException { - return new BaseBigtableDataSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return BigtableStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return BigtableStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return BigtableStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return BigtableStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return BigtableStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return BigtableStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return BigtableStubSettings.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 BaseBigtableDataSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for BaseBigtableDataSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(BigtableStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(BigtableStubSettings.newBuilder()); - } - - protected Builder(BaseBigtableDataSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(BigtableStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public BigtableStubSettings.Builder getStubSettingsBuilder() { - return ((BigtableStubSettings.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 readRows. */ - public ServerStreamingCallSettings.Builder - readRowsSettings() { - return getStubSettingsBuilder().readRowsSettings(); - } - - /** Returns the builder for the settings used for calls to sampleRowKeys. */ - public ServerStreamingCallSettings.Builder - sampleRowKeysSettings() { - return getStubSettingsBuilder().sampleRowKeysSettings(); - } - - /** Returns the builder for the settings used for calls to mutateRow. */ - public UnaryCallSettings.Builder mutateRowSettings() { - return getStubSettingsBuilder().mutateRowSettings(); - } - - /** Returns the builder for the settings used for calls to mutateRows. */ - public ServerStreamingCallSettings.Builder - mutateRowsSettings() { - return getStubSettingsBuilder().mutateRowsSettings(); - } - - /** Returns the builder for the settings used for calls to checkAndMutateRow. */ - public UnaryCallSettings.Builder - checkAndMutateRowSettings() { - return getStubSettingsBuilder().checkAndMutateRowSettings(); - } - - /** Returns the builder for the settings used for calls to readModifyWriteRow. */ - public UnaryCallSettings.Builder - readModifyWriteRowSettings() { - return getStubSettingsBuilder().readModifyWriteRowSettings(); - } - - @Override - public BaseBigtableDataSettings build() throws IOException { - return new BaseBigtableDataSettings(this); - } - } -} diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java index 3518f132dd99..f80d33a1b1e9 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java @@ -228,7 +228,8 @@ public static class Builder { /** * Initializes a new Builder with sane defaults for all settings. * - *

Most defaults are extracted from BaseBigtableDataSettings, however some of the more + *

Most defaults are extracted from {@link + * com.google.cloud.bigtable.data.v2.stub.BigtableStubSettings}, however some of the more * complex defaults are configured explicitly here. Once the overlayed defaults are configured, * the base settings are augmented to work with overlayed functionality (like disabling retries * in the underlying GAPIC client for batching). diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/package-info.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/package-info.java index 0f3011b71eed..5f4193d06365 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/package-info.java @@ -15,25 +15,8 @@ */ /** - * A client to Cloud Bigtable API. + * A client for the Cloud Bigtable data API. * - *

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

====================== BaseBigtableDataClient ====================== - * - *

Service Description: Service for reading from and writing to existing Bigtable tables. - * - *

Sample for BaseBigtableDataClient: - * - *

- * 
- * try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
- *   TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
- *   ByteString rowKey = ByteString.copyFromUtf8("");
- *   List<Mutation> mutations = new ArrayList<>();
- *   MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName, rowKey, mutations);
- * }
- * 
- * 
+ * @see com.google.cloud.bigtable.data.v2.BigtableDataClient for usage. */ package com.google.cloud.bigtable.data.v2; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java index a2d51e0db1a1..dbbb01230653 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.data.v2.stub; -import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.ServerStreamingCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -34,13 +34,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Cloud Bigtable API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public abstract class BigtableStub implements BackgroundResource { public ServerStreamingCallable readRowsCallable() { diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java index d422250cb548..905e6d1012d6 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java @@ -17,6 +17,7 @@ import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -53,33 +54,9 @@ import org.threeten.bp.Duration; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link BigtableStub}. - * - *

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

    - *
  • The default service address (bigtable.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 mutateRow to 30 seconds: - * - *

- * 
- * BigtableStubSettings.Builder baseBigtableDataSettingsBuilder =
- *     BigtableStubSettings.newBuilder();
- * baseBigtableDataSettingsBuilder.mutateRowSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BigtableStubSettings baseBigtableDataSettings = baseBigtableDataSettingsBuilder.build();
- * 
- * 
- */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi +@InternalApi public class BigtableStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java index 1fa5cda523be..098670bb1ca3 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java @@ -15,7 +15,6 @@ */ package com.google.cloud.bigtable.data.v2.stub; -import com.google.api.core.InternalApi; import com.google.api.gax.batching.BatchingSettings; import com.google.api.gax.batching.FlowControlSettings; import com.google.api.gax.batching.FlowController.LimitExceededBehavior; @@ -74,11 +73,7 @@ * * BigtableDataSettings settings = builder.build(); * } - * - *

This class is considered an internal implementation detail and not meant to be used by - * applications. */ -@InternalApi public class EnhancedBigtableStubSettings extends StubSettings { // The largest message that can be received is a 256 MB ReadRowsResponse. private static final int MAX_MESSAGE_SIZE = 256 * 1024 * 1024; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java index 78e88a175779..b0230acd2de4 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java @@ -16,6 +16,7 @@ package com.google.cloud.bigtable.data.v2.stub; import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -35,13 +36,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable API. - * - *

This class is for advanced usage. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +@InternalApi public class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java index 2cc7f1b0b092..a98cba8386d2 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java @@ -15,7 +15,7 @@ */ package com.google.cloud.bigtable.data.v2.stub; -import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -45,13 +45,9 @@ import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Cloud Bigtable API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ +/** For internal use only. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@InternalApi public class GrpcBigtableStub extends BigtableStub { private static final MethodDescriptor diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/package-info.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/package-info.java index e109cc76d4a1..d5f08a3976de 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/package-info.java @@ -13,5 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** General purpose utilities that might be moved to gax at some point in the future. */ +/** + * General purpose utilities that might be moved to gax at some point in the future. + * + *

For internal use, public for technical reasons. + */ +@InternalApi package com.google.cloud.bigtable.gaxx; + +import com.google.api.core.InternalApi; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java index db5b7a4238a2..2c3157249a9f 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java @@ -19,5 +19,10 @@ *

It is intended for situations when a stream needs to be transformed in such a way where the * incoming responses do not map 1:1 to the output responses. This is used to transform * ReadRowsResponse chunks into logical rows, but is generic enough to be used for other purposes. + * + *

For internal use, public for technical reasons. */ +@InternalApi package com.google.cloud.bigtable.gaxx.reframing; + +import com.google.api.core.InternalApi; diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/ApiResultRetryAlgorithm.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/ApiResultRetryAlgorithm.java index 776208d95026..c7f3d18b6241 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/ApiResultRetryAlgorithm.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/ApiResultRetryAlgorithm.java @@ -15,12 +15,15 @@ */ package com.google.cloud.bigtable.gaxx.retrying; +import com.google.api.core.InternalApi; import com.google.api.gax.retrying.ResultRetryAlgorithm; import com.google.api.gax.retrying.TimedAttemptSettings; import com.google.api.gax.rpc.ApiException; import com.google.api.gax.rpc.DeadlineExceededException; import org.threeten.bp.Duration; +/** For internal use, public for technical reasons. */ +@InternalApi public class ApiResultRetryAlgorithm implements ResultRetryAlgorithm { // Duration to sleep on if the error is DEADLINE_EXCEEDED. public static final Duration DEADLINE_SLEEP_DURATION = Duration.ofMillis(1); diff --git a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/package-info.java b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/package-info.java index c8269a48db52..ad43933014a3 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/package-info.java +++ b/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/package-info.java @@ -17,6 +17,48 @@ /** * A client for Cloud Bigtable. * + *

Concepts + * + *

Conceptually Cloud Bigtable is composed of instances, clusters nodes and Tables. + * + *

+ *
Instances + *
Instances are mostly containers for your clusters, nodes and tables, which do all of the + * real work. + *
Clusters + *
Clusters represent the actual Cloud Bigtable service. Each cluster belongs to a single + * Cloud Bigtable instance, and an instance can have up to 4 clusters. When your application + * sends requests to a Cloud Bigtable instance, those requests are actually handled by one of + * the clusters in the instance. + *
Nodes + *
Each cluster in a production instance has 3 or more nodes, which are compute resources that + * Cloud Bigtable uses to manage your data. + *
Tables + *
Tables contain the actual data and are replicated across all of the clusters in an + * instance. + *
+ * + *

Clients

+ * + *

The Cloud Bigtable API consists of 2 parts: + * + *

+ *
Data API + *
Allows callers to persist and query data in a table. It's exposed by {@link + * com.google.cloud.bigtable.data.v2.BigtableDataClient}. + *
Admin API + *
Allows callers to create and manage Instances, Clusters, etc. This api is exposed by: + *
    + *
  • {@link com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient} for Instance + * and Cluster level resources. + *
  • {@link com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient} for table + * management + *
+ *
+ * * @see com.google.cloud.bigtable.data.v2.BigtableDataClient For the data client. + * @see com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminSettings For the instance admin + * client. + * @see com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient For the table admin client. */ package com.google.cloud.bigtable; diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/HiddenGapicApiTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/HiddenGapicApiTest.java new file mode 100644 index 000000000000..354a725b6e5c --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/HiddenGapicApiTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2019 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.assertWithMessage; + +import com.google.api.core.InternalApi; +import com.google.cloud.bigtable.admin.v2.stub.BigtableInstanceAdminStub; +import com.google.cloud.bigtable.admin.v2.stub.BigtableTableAdminStub; +import com.google.cloud.bigtable.admin.v2.stub.GrpcBigtableInstanceAdminCallableFactory; +import com.google.cloud.bigtable.admin.v2.stub.GrpcBigtableInstanceAdminStub; +import com.google.cloud.bigtable.admin.v2.stub.GrpcBigtableTableAdminCallableFactory; +import com.google.cloud.bigtable.admin.v2.stub.GrpcBigtableTableAdminStub; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * Tests that the underlying GAPIC api is marked as {@code @InternalApi}. This transformation + * happens in synth.py. + */ +@RunWith(Parameterized.class) +public class HiddenGapicApiTest { + private Class testClass; + + @Parameters + public static Object[] data() { + return new Object[] { + GrpcBigtableInstanceAdminCallableFactory.class, + GrpcBigtableInstanceAdminStub.class, + BaseBigtableInstanceAdminSettings.class, + GrpcBigtableTableAdminCallableFactory.class, + GrpcBigtableTableAdminStub.class, + BaseBigtableTableAdminSettings.class, + BigtableInstanceAdminStub.class, + BigtableTableAdminStub.class, + BaseBigtableInstanceAdminClient.class, + BaseBigtableTableAdminClient.class, + }; + } + + public HiddenGapicApiTest(Class testClass) { + this.testClass = testClass; + } + + @Test + public void test() { + assertWithMessage("%s should be annotated with @InternaOnly", testClass.getName()) + .that(testClass.getAnnotation(InternalApi.class)) + .isNotNull(); + } +} diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java deleted file mode 100644 index b42279ebc2ff..000000000000 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2019 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.data.v2; - -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.grpc.testing.MockStreamObserver; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StatusCode; -import com.google.bigtable.v2.CheckAndMutateRowRequest; -import com.google.bigtable.v2.CheckAndMutateRowResponse; -import com.google.bigtable.v2.MutateRowRequest; -import com.google.bigtable.v2.MutateRowResponse; -import com.google.bigtable.v2.MutateRowsRequest; -import com.google.bigtable.v2.MutateRowsResponse; -import com.google.bigtable.v2.Mutation; -import com.google.bigtable.v2.ReadModifyWriteRowRequest; -import com.google.bigtable.v2.ReadModifyWriteRowResponse; -import com.google.bigtable.v2.ReadModifyWriteRule; -import com.google.bigtable.v2.ReadRowsRequest; -import com.google.bigtable.v2.ReadRowsResponse; -import com.google.bigtable.v2.RowFilter; -import com.google.bigtable.v2.SampleRowKeysRequest; -import com.google.bigtable.v2.SampleRowKeysResponse; -import com.google.bigtable.v2.TableName; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.ByteString; -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 BaseBigtableDataClientTest { - private static MockBigtable mockBigtable; - private static MockServiceHelper serviceHelper; - private BaseBigtableDataClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockBigtable = new MockBigtable(); - serviceHelper = - new MockServiceHelper("in-process-1", Arrays.asList(mockBigtable)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - BaseBigtableDataSettings settings = - BaseBigtableDataSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = BaseBigtableDataClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void readRowsTest() throws Exception { - ByteString lastScannedRowKey = ByteString.copyFromUtf8("-126"); - ReadRowsResponse expectedResponse = - ReadRowsResponse.newBuilder().setLastScannedRowKey(lastScannedRowKey).build(); - mockBigtable.addResponse(expectedResponse); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ReadRowsRequest request = - ReadRowsRequest.newBuilder().setTableName(tableName.toString()).build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = client.readRowsCallable(); - callable.serverStreamingCall(request, responseObserver); - - List actualResponses = responseObserver.future().get(); - Assert.assertEquals(1, actualResponses.size()); - Assert.assertEquals(expectedResponse, actualResponses.get(0)); - } - - @Test - @SuppressWarnings("all") - public void readRowsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ReadRowsRequest request = - ReadRowsRequest.newBuilder().setTableName(tableName.toString()).build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = client.readRowsCallable(); - callable.serverStreamingCall(request, responseObserver); - - try { - List actualResponses = responseObserver.future().get(); - Assert.fail("No exception thrown"); - } catch (ExecutionException e) { - Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - - @Test - @SuppressWarnings("all") - public void sampleRowKeysTest() throws Exception { - ByteString rowKey = ByteString.copyFromUtf8("122"); - long offsetBytes = 889884095L; - SampleRowKeysResponse expectedResponse = - SampleRowKeysResponse.newBuilder().setRowKey(rowKey).setOffsetBytes(offsetBytes).build(); - mockBigtable.addResponse(expectedResponse); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - SampleRowKeysRequest request = - SampleRowKeysRequest.newBuilder().setTableName(tableName.toString()).build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = - client.sampleRowKeysCallable(); - callable.serverStreamingCall(request, responseObserver); - - List actualResponses = responseObserver.future().get(); - Assert.assertEquals(1, actualResponses.size()); - Assert.assertEquals(expectedResponse, actualResponses.get(0)); - } - - @Test - @SuppressWarnings("all") - public void sampleRowKeysExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - SampleRowKeysRequest request = - SampleRowKeysRequest.newBuilder().setTableName(tableName.toString()).build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = - client.sampleRowKeysCallable(); - callable.serverStreamingCall(request, responseObserver); - - try { - List actualResponses = responseObserver.future().get(); - Assert.fail("No exception thrown"); - } catch (ExecutionException e) { - Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - - @Test - @SuppressWarnings("all") - public void mutateRowTest() { - MutateRowResponse expectedResponse = MutateRowResponse.newBuilder().build(); - mockBigtable.addResponse(expectedResponse); - - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - List mutations = new ArrayList<>(); - - MutateRowResponse actualResponse = client.mutateRow(tableName, rowKey, mutations); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtable.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - MutateRowRequest actualRequest = (MutateRowRequest) actualRequests.get(0); - - Assert.assertEquals(tableName, TableName.parse(actualRequest.getTableName())); - Assert.assertEquals(rowKey, actualRequest.getRowKey()); - Assert.assertEquals(mutations, actualRequest.getMutationsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void mutateRowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - - try { - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - List mutations = new ArrayList<>(); - - client.mutateRow(tableName, rowKey, mutations); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void mutateRowsTest() throws Exception { - MutateRowsResponse expectedResponse = MutateRowsResponse.newBuilder().build(); - mockBigtable.addResponse(expectedResponse); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - List entries = new ArrayList<>(); - MutateRowsRequest request = - MutateRowsRequest.newBuilder() - .setTableName(tableName.toString()) - .addAllEntries(entries) - .build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = - client.mutateRowsCallable(); - callable.serverStreamingCall(request, responseObserver); - - List actualResponses = responseObserver.future().get(); - Assert.assertEquals(1, actualResponses.size()); - Assert.assertEquals(expectedResponse, actualResponses.get(0)); - } - - @Test - @SuppressWarnings("all") - public void mutateRowsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - List entries = new ArrayList<>(); - MutateRowsRequest request = - MutateRowsRequest.newBuilder() - .setTableName(tableName.toString()) - .addAllEntries(entries) - .build(); - - MockStreamObserver responseObserver = new MockStreamObserver<>(); - - ServerStreamingCallable callable = - client.mutateRowsCallable(); - callable.serverStreamingCall(request, responseObserver); - - try { - List actualResponses = responseObserver.future().get(); - Assert.fail("No exception thrown"); - } catch (ExecutionException e) { - Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - - @Test - @SuppressWarnings("all") - public void checkAndMutateRowTest() { - boolean predicateMatched = true; - CheckAndMutateRowResponse expectedResponse = - CheckAndMutateRowResponse.newBuilder().setPredicateMatched(predicateMatched).build(); - mockBigtable.addResponse(expectedResponse); - - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - RowFilter predicateFilter = RowFilter.newBuilder().build(); - List trueMutations = new ArrayList<>(); - List falseMutations = new ArrayList<>(); - - CheckAndMutateRowResponse actualResponse = - client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtable.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CheckAndMutateRowRequest actualRequest = (CheckAndMutateRowRequest) actualRequests.get(0); - - Assert.assertEquals(tableName, TableName.parse(actualRequest.getTableName())); - Assert.assertEquals(rowKey, actualRequest.getRowKey()); - Assert.assertEquals(predicateFilter, actualRequest.getPredicateFilter()); - Assert.assertEquals(trueMutations, actualRequest.getTrueMutationsList()); - Assert.assertEquals(falseMutations, actualRequest.getFalseMutationsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void checkAndMutateRowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - - try { - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - RowFilter predicateFilter = RowFilter.newBuilder().build(); - List trueMutations = new ArrayList<>(); - List falseMutations = new ArrayList<>(); - - client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void readModifyWriteRowTest() { - ReadModifyWriteRowResponse expectedResponse = ReadModifyWriteRowResponse.newBuilder().build(); - mockBigtable.addResponse(expectedResponse); - - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - List rules = new ArrayList<>(); - - ReadModifyWriteRowResponse actualResponse = client.readModifyWriteRow(tableName, rowKey, rules); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockBigtable.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ReadModifyWriteRowRequest actualRequest = (ReadModifyWriteRowRequest) actualRequests.get(0); - - Assert.assertEquals(tableName, TableName.parse(actualRequest.getTableName())); - Assert.assertEquals(rowKey, actualRequest.getRowKey()); - Assert.assertEquals(rules, actualRequest.getRulesList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void readModifyWriteRowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockBigtable.addException(exception); - - try { - TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); - ByteString rowKey = ByteString.copyFromUtf8("122"); - List rules = new ArrayList<>(); - - client.readModifyWriteRow(tableName, rowKey, rules); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/HiddenGapicApiTest.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/HiddenGapicApiTest.java new file mode 100644 index 000000000000..7c302b7cbd30 --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/HiddenGapicApiTest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2019 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.data.v2; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.api.core.InternalApi; +import com.google.cloud.bigtable.data.v2.stub.BigtableStub; +import com.google.cloud.bigtable.data.v2.stub.BigtableStubSettings; +import com.google.cloud.bigtable.data.v2.stub.GrpcBigtableCallableFactory; +import com.google.cloud.bigtable.data.v2.stub.GrpcBigtableStub; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * Tests that the underlying GAPIC api is marked as {@code @InternalApi}. This transformation + * happens in synth.py. + */ +@RunWith(Parameterized.class) +public class HiddenGapicApiTest { + private Class testClass; + + @Parameters + public static Object[] data() { + return new Object[] { + BigtableStub.class, + BigtableStubSettings.class, + GrpcBigtableStub.class, + GrpcBigtableCallableFactory.class + }; + } + + public HiddenGapicApiTest(Class testClass) { + this.testClass = testClass; + } + + @Test + public void test() { + assertWithMessage("%s should be annotated with @InternaOnly", testClass.getName()) + .that(testClass.getAnnotation(InternalApi.class)) + .isNotNull(); + } +} diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java deleted file mode 100644 index 74fd84e27253..000000000000 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 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.data.v2; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockBigtable implements MockGrpcService { - private final MockBigtableImpl serviceImpl; - - public MockBigtable() { - serviceImpl = new MockBigtableImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java deleted file mode 100644 index f253a16dc2fe..000000000000 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2019 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.data.v2; - -import com.google.api.core.BetaApi; -import com.google.bigtable.v2.BigtableGrpc.BigtableImplBase; -import com.google.bigtable.v2.CheckAndMutateRowRequest; -import com.google.bigtable.v2.CheckAndMutateRowResponse; -import com.google.bigtable.v2.MutateRowRequest; -import com.google.bigtable.v2.MutateRowResponse; -import com.google.bigtable.v2.MutateRowsRequest; -import com.google.bigtable.v2.MutateRowsResponse; -import com.google.bigtable.v2.ReadModifyWriteRowRequest; -import com.google.bigtable.v2.ReadModifyWriteRowResponse; -import com.google.bigtable.v2.ReadRowsRequest; -import com.google.bigtable.v2.ReadRowsResponse; -import com.google.bigtable.v2.SampleRowKeysRequest; -import com.google.bigtable.v2.SampleRowKeysResponse; -import com.google.protobuf.AbstractMessage; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockBigtableImpl extends BigtableImplBase { - private List requests; - private Queue responses; - - public MockBigtableImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void readRows(ReadRowsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ReadRowsResponse) { - requests.add(request); - responseObserver.onNext((ReadRowsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void sampleRowKeys( - SampleRowKeysRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof SampleRowKeysResponse) { - requests.add(request); - responseObserver.onNext((SampleRowKeysResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void mutateRow( - MutateRowRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof MutateRowResponse) { - requests.add(request); - responseObserver.onNext((MutateRowResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void mutateRows( - MutateRowsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof MutateRowsResponse) { - requests.add(request); - responseObserver.onNext((MutateRowsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void checkAndMutateRow( - CheckAndMutateRowRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof CheckAndMutateRowResponse) { - requests.add(request); - responseObserver.onNext((CheckAndMutateRowResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void readModifyWriteRow( - ReadModifyWriteRowRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ReadModifyWriteRowResponse) { - requests.add(request); - responseObserver.onNext((ReadModifyWriteRowResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/google-cloud-clients/google-cloud-bigtable/synth.metadata b/google-cloud-clients/google-cloud-bigtable/synth.metadata index 52144512a73f..8e1fc91babf5 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.metadata +++ b/google-cloud-clients/google-cloud-bigtable/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-04-02T07:36:18.493403Z", + "updateTime": "2019-04-29T22:56:01.195702Z", "sources": [ { "generator": { "name": "artman", - "version": "0.16.22", - "dockerImage": "googleapis/artman@sha256:e7f9554322a8aa1416c122c918fdc4cdec8cfe816f027fc948dec0be7edef320" + "version": "0.17.1", + "dockerImage": "googleapis/artman@sha256:a40ca4dd4ef031c0ded4df4909ffdf7b3f20d29b23e682ef991eb60ba0ca6025" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "6c48ab5aef47dc14e02e2dc718d232a28067129d", - "internalRef": "241437588" + "sha": "be3005c8a16e8424d0330e977ac78f2976bf01d3", + "internalRef": "245840921" } } ], diff --git a/google-cloud-clients/google-cloud-bigtable/synth.py b/google-cloud-clients/google-cloud-bigtable/synth.py index f2b6178ac702..0909f5291d95 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -14,39 +14,112 @@ """This script is used to synthesize generated parts of this library.""" +import re import synthtool as s import synthtool.gcp as gcp import synthtool.languages.java as java -gapic = gcp.GAPICGenerator() +# TODO: try to move the GAPIC surface hiding to the gapic-generator: +# https://github.com/googleapis/gapic-generator/issues/2742 -data_library = gapic.java_library( +def main(): + gapic = gcp.GAPICGenerator() + + generate_data_api(gapic) + generate_admin_api(gapic) + + java.format_code('src') + + +def generate_data_api(gapic): + library = gapic.java_library( service='bigtable', version='v2', config_path='/google/bigtable/artman_bigtable.yaml', artman_output_name='') + # Excludes are relative to source `gapic-google-cloud-bigtable-v2/src` + excludes = [ + "build.gradle", + "pom.xml", + "README.md", + "src/main/java/com/google/cloud/bigtable/data/v2/package-info.java", + "src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java", + "src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java", + "src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java", + "src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java", + "src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java", + ] -s.copy(data_library / 'gapic-google-cloud-bigtable-v2/src', 'src') -s.copy(data_library / 'grpc-google-cloud-bigtable-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-v2/src') -s.copy(data_library / 'proto-google-cloud-bigtable-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-v2/src') + # Paths are relative to the destination, which is the current working directory + internal_only = [ + "src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java", + 'src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java', + "src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java", + "src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java", + ] -java.format_code('../../google-api-grpc/grpc-google-cloud-bigtable-v2/src') -java.format_code('../../google-api-grpc/proto-google-cloud-bigtable-v2/src') + s.copy(library / 'gapic-google-cloud-bigtable-v2', '.', excludes=excludes) + s.copy(library / 'grpc-google-cloud-bigtable-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-v2/src') + s.copy(library / 'proto-google-cloud-bigtable-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-v2/src') + make_internal_only(internal_only) + + java.format_code('../../google-api-grpc/grpc-google-cloud-bigtable-v2/src') + java.format_code('../../google-api-grpc/proto-google-cloud-bigtable-v2/src') + + +def generate_admin_api(gapic): + library = gapic.java_library( + service='bigtable-admin', + version='v2', + config_path='/google/bigtable/admin/artman_bigtableadmin.yaml', + artman_output_name='') + + # Excludes are relative to source `gapic-google-cloud-bigtable-v2/src` + excludes = [ + "main/java/com/google/cloud/bigtable/admin/v2/package-info.java", + ] + + # Paths are relative to the destination, which is the current working directory + internal_only = [ + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminSettings.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminSettings.java', + + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableInstanceAdminClient.java', + 'src/main/java/com/google/cloud/bigtable/admin/v2/BaseBigtableTableAdminClient.java', + ] + + s.copy(library / 'gapic-google-cloud-bigtable-admin-v2/src', 'src', excludes=excludes) + s.copy(library / 'grpc-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src') + s.copy(library / 'proto-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src') + + make_internal_only(internal_only) + + java.format_code('../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src') + java.format_code('../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src') -admin_library = gapic.java_library( - service='bigtable-admin', - version='v2', - config_path='/google/bigtable/admin/artman_bigtableadmin.yaml', - artman_output_name='') +def make_internal_only(sources): + """Annotates all toplevel classes with `@InternalOnly`""" + # Insert InternalOnly import in the non-static. + s.replace(sources, + before=r'^(import (?!static).*?\n)\n', + after=r'\1import com.google.api.core.InternalApi;\n\n', + flags=re.MULTILINE | re.DOTALL) -s.copy(admin_library / 'gapic-google-cloud-bigtable-admin-v2/src', 'src') -s.copy(admin_library / 'grpc-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src') -s.copy(admin_library / 'proto-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src') + # Replace javadoc and annotations before every public class with InternalApi + # javadoc and annotation + s.replace(sources, -java.format_code('../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src') -java.format_code('../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src') + before=r'/\*\*.+?\*/\n(?:^@[^\n]*\n)*(?=public [a-zA-B ]*class)', + after='/** For internal use only. */\n@Generated("by gapic-generator")\n@InternalApi\n', + flags=re.MULTILINE | re.DOTALL) -java.format_code('./src') +main()