From f32cdcf5cf37650021546418fd221db002b9a530 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 11:42:06 -0400 Subject: [PATCH 1/7] Bigtable: clean up the public surface * Exclude autogenerated files that aren't used * Internal implementation details are now package private * Internal implementation details that are needed by other pacakges are now @InternalApi (ie. pagination wrappers in Client) * package-info.java not document the public surface instead of the autogen one * EnhancedBigtableStubSetting are now public api * synth.py is responsible for the transformations --- .../v2/BaseBigtableInstanceAdminClient.java | 74 +- .../v2/BaseBigtableInstanceAdminSettings.java | 3 +- .../v2/BaseBigtableTableAdminClient.java | 76 +- .../v2/BaseBigtableTableAdminSettings.java | 2 +- .../cloud/bigtable/admin/v2/package-info.java | 43 +- .../v2/stub/BigtableInstanceAdminStub.java | 11 +- .../admin/v2/stub/BigtableTableAdminStub.java | 11 +- ...cBigtableInstanceAdminCallableFactory.java | 2 +- .../stub/GrpcBigtableInstanceAdminStub.java | 2 +- ...GrpcBigtableTableAdminCallableFactory.java | 2 +- .../v2/stub/GrpcBigtableTableAdminStub.java | 2 +- .../data/v2/BaseBigtableDataClient.java | 698 ------------------ .../data/v2/BaseBigtableDataSettings.java | 245 ------ .../data/v2/BigtableDataSettings.java | 3 +- .../cloud/bigtable/data/v2/package-info.java | 21 +- .../bigtable/data/v2/stub/BigtableStub.java | 2 +- .../data/v2/stub/BigtableStubSettings.java | 2 +- .../v2/stub/EnhancedBigtableStubSettings.java | 5 - .../v2/stub/GrpcBigtableCallableFactory.java | 2 +- .../data/v2/stub/GrpcBigtableStub.java | 2 +- .../cloud/bigtable/gaxx/package-info.java | 9 +- .../bigtable/gaxx/reframing/package-info.java | 5 + .../retrying/ApiResultRetryAlgorithm.java | 3 + .../google/cloud/bigtable/package-info.java | 42 ++ .../data/v2/BaseBigtableDataClientTest.java | 383 ---------- .../cloud/bigtable/data/v2/MockBigtable.java | 57 -- .../bigtable/data/v2/MockBigtableImpl.java | 161 ---- .../google-cloud-bigtable/synth.metadata | 10 +- .../google-cloud-bigtable/synth.py | 117 ++- 29 files changed, 193 insertions(+), 1802 deletions(-) delete mode 100644 google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java delete mode 100644 google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java delete mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java delete mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java delete mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java 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..9f8164d03e06 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; @@ -72,79 +73,10 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -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);
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi +/** For internal use only. */ +@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..e7bb6605d808 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 @@ -94,8 +94,7 @@ */ @Generated("by gapic-generator") @BetaApi -public class BaseBigtableInstanceAdminSettings - extends ClientSettings { +class BaseBigtableInstanceAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createInstance. */ public UnaryCallSettings createInstanceSettings() { return ((BigtableInstanceAdminStubSettings) getStubSettings()).createInstanceSettings(); 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..8ef1fae56387 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; @@ -61,81 +62,10 @@ import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. - * - *

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

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) {
- *   InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
- *   String tableId = "";
- *   Table table = Table.newBuilder().build();
- *   Table response = baseBigtableTableAdminClient.createTable(parent, tableId, table);
- * }
- * 
- * 
- * - *

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

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

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

See the individual methods for example code. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

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

To customize credentials: - * - *

- * 
- * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings =
- *     BaseBigtableTableAdminSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * BaseBigtableTableAdminClient baseBigtableTableAdminClient =
- *     BaseBigtableTableAdminClient.create(baseBigtableTableAdminSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings =
- *     BaseBigtableTableAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * BaseBigtableTableAdminClient baseBigtableTableAdminClient =
- *     BaseBigtableTableAdminClient.create(baseBigtableTableAdminSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi +/** For internal use only. */ +@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..05fbd653b7b5 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 @@ -86,7 +86,7 @@ */ @Generated("by gapic-generator") @BetaApi -public class BaseBigtableTableAdminSettings extends ClientSettings { +class BaseBigtableTableAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createTable. */ public UnaryCallSettings createTableSettings() { return ((BigtableTableAdminStubSettings) getStubSettings()).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..fef69b12f554 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,12 @@ */ /** - * 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..1a3f9c36c3ac 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; @@ -54,16 +55,10 @@ import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +/** For internal use only. */ +@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..0b003ffe960e 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; @@ -46,16 +47,10 @@ import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +/** For internal use only. */ +@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..72a9df163385 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 @@ -42,7 +42,7 @@ */ @Generated("by gapic-generator") @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { +class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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..1769c0d2a005 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 @@ -75,7 +75,7 @@ */ @Generated("by gapic-generator") @BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { +class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { private static final MethodDescriptor createInstanceMethodDescriptor = 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..c2d6b0754cdb 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 @@ -42,7 +42,7 @@ */ @Generated("by gapic-generator") @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { +class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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..82943c1372d9 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 @@ -67,7 +67,7 @@ */ @Generated("by gapic-generator") @BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { +class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { private static final MethodDescriptor createTableMethodDescriptor = MethodDescriptor.newBuilder() 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..470c35577325 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 @@ -41,7 +41,7 @@ */ @Generated("by gapic-generator") @BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class BigtableStub implements BackgroundResource { +abstract class BigtableStub implements BackgroundResource { public ServerStreamingCallable readRowsCallable() { throw new UnsupportedOperationException("Not implemented: 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..b58e84cef5bd 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 @@ -80,7 +80,7 @@ */ @Generated("by gapic-generator") @BetaApi -public class BigtableStubSettings extends StubSettings { +class BigtableStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() 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..79a87e1b64c5 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 @@ -42,7 +42,7 @@ */ @Generated("by gapic-generator") @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { +class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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..82a5b3fb4747 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 @@ -52,7 +52,7 @@ */ @Generated("by gapic-generator") @BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcBigtableStub extends BigtableStub { +class GrpcBigtableStub extends BigtableStub { private static final MethodDescriptor readRowsMethodDescriptor = 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/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/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..8a59b6903941 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-29T15:28:19.046154Z", "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": "808110e242c682d7ac2bab6d9c49fc3bf72d7604", + "internalRef": "245313728" } } ], diff --git a/google-cloud-clients/google-cloud-bigtable/synth.py b/google-cloud-clients/google-cloud-bigtable/synth.py index f2b6178ac702..b9129bd09d31 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -14,39 +14,120 @@ """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() +def main(): + gapic = gcp.GAPICGenerator() -data_library = gapic.java_library( + 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 = [ + "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 + pkg_private = [ + "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_package_private(pkg_private) -admin_library = gapic.java_library( - service='bigtable-admin', - version='v2', - config_path='/google/bigtable/admin/artman_bigtableadmin.yaml', - artman_output_name='') + 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 + pkg_private = [ + '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' + ] + + # Paths are relative to the destination, which is the current working directory + internal_only = [ + '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_package_private(pkg_private) + 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') + + +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) + + # Replace javadoc and annotations before every public class with InternalApi + # javadoc and annotation + s.replace(sources, + before=r'/\*\*.+?\*/\n(?:^@[^\n]*\n)*(?=public [a-zA-B ]*class)', + after='/** For internal use only. */\n@InternalApi\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') +def make_package_private(sources): + """Strips all toplevel classes' public visibility.""" + s.replace(sources, + before=r'^public (?=.*(?:class|interface) )', + after='', + flags=re.MULTILINE) -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') -java.format_code('./src') +main() From 427d1667b3e79c52d5f5eb5d7347be64b3ee2170 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 13:34:13 -0400 Subject: [PATCH 2/7] exclude gradle build files --- google-cloud-clients/google-cloud-bigtable/synth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google-cloud-clients/google-cloud-bigtable/synth.py b/google-cloud-clients/google-cloud-bigtable/synth.py index b9129bd09d31..9e50446a2a59 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -37,6 +37,7 @@ def generate_data_api(gapic): # 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", From 90a9f52704faf760c3c09241e1e0cdda4f8db48f Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 13:36:37 -0400 Subject: [PATCH 3/7] fix whitespace --- .../java/com/google/cloud/bigtable/admin/v2/package-info.java | 1 - 1 file changed, 1 deletion(-) 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 fef69b12f554..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 @@ -22,5 +22,4 @@ * @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; From f11cacc94ae8d070c0eb2c7ad7f1103ec5ea386b Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 14:30:10 -0400 Subject: [PATCH 4/7] Fix tests by making things InternalApi instead of package-private. Mockito can't mock classes which have package-private parents --- .../v2/BaseBigtableInstanceAdminSettings.java | 34 +++---------------- .../v2/BaseBigtableTableAdminSettings.java | 33 +++--------------- ...cBigtableInstanceAdminCallableFactory.java | 13 +++---- .../stub/GrpcBigtableInstanceAdminStub.java | 13 +++---- ...GrpcBigtableTableAdminCallableFactory.java | 13 +++---- .../v2/stub/GrpcBigtableTableAdminStub.java | 13 +++---- .../bigtable/data/v2/stub/BigtableStub.java | 14 +++----- .../data/v2/stub/BigtableStubSettings.java | 33 +++--------------- .../v2/stub/GrpcBigtableCallableFactory.java | 13 +++---- .../data/v2/stub/GrpcBigtableStub.java | 14 +++----- .../google-cloud-bigtable/synth.metadata | 2 +- .../google-cloud-bigtable/synth.py | 20 +++-------- 12 files changed, 46 insertions(+), 169 deletions(-) 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 e7bb6605d808..a5779e8b35ee 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; @@ -64,37 +65,12 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link BaseBigtableInstanceAdminClient}. - * - *

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

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

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

- * 
- * BaseBigtableInstanceAdminSettings.Builder baseBigtableInstanceAdminSettingsBuilder =
- *     BaseBigtableInstanceAdminSettings.newBuilder();
- * baseBigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BaseBigtableInstanceAdminSettings baseBigtableInstanceAdminSettings = baseBigtableInstanceAdminSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -class BaseBigtableInstanceAdminSettings extends ClientSettings { +/** For internal use only. */ +@InternalApi +public class BaseBigtableInstanceAdminSettings + extends ClientSettings { /** Returns the object with the settings used for calls to createInstance. */ public UnaryCallSettings createInstanceSettings() { return ((BigtableInstanceAdminStubSettings) getStubSettings()).createInstanceSettings(); 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 05fbd653b7b5..d9419ebec474 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; @@ -56,37 +57,11 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link BaseBigtableTableAdminClient}. - * - *

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

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

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

- * 
- * BaseBigtableTableAdminSettings.Builder baseBigtableTableAdminSettingsBuilder =
- *     BaseBigtableTableAdminSettings.newBuilder();
- * baseBigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * BaseBigtableTableAdminSettings baseBigtableTableAdminSettings = baseBigtableTableAdminSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -class BaseBigtableTableAdminSettings extends ClientSettings { +/** For internal use only. */ +@InternalApi +public class BaseBigtableTableAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createTable. */ public UnaryCallSettings createTableSettings() { return ((BigtableTableAdminStubSettings) getStubSettings()).createTableSettings(); 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 72a9df163385..9fc5cdaf0669 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; @@ -32,17 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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 1769c0d2a005..949b37ce6c2d 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; @@ -65,17 +66,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { private static final MethodDescriptor createInstanceMethodDescriptor = 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 c2d6b0754cdb..73aaf460c984 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; @@ -32,17 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable Admin API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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 82943c1372d9..a575a8891304 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; @@ -57,17 +58,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { private static final MethodDescriptor createTableMethodDescriptor = MethodDescriptor.newBuilder() 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 470c35577325..54174b6269ad 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; @@ -31,17 +31,11 @@ import com.google.bigtable.v2.ReadRowsResponse; import com.google.bigtable.v2.SampleRowKeysRequest; import com.google.bigtable.v2.SampleRowKeysResponse; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -abstract class BigtableStub implements BackgroundResource { +/** For internal use only. */ +@InternalApi +public abstract class BigtableStub implements BackgroundResource { public ServerStreamingCallable readRowsCallable() { throw new UnsupportedOperationException("Not implemented: 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 b58e84cef5bd..6bd7057bee1c 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; @@ -49,38 +50,12 @@ import com.google.common.collect.Lists; import java.io.IOException; import java.util.List; -import javax.annotation.Generated; 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();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -class BigtableStubSettings extends StubSettings { +/** For internal use only. */ +@InternalApi +public class BigtableStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() 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 79a87e1b64c5..02d5f88cbf5e 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; @@ -32,17 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Cloud Bigtable API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, 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 82a5b3fb4747..14d0b1690443 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; @@ -42,17 +42,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -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. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -class GrpcBigtableStub extends BigtableStub { +/** For internal use only. */ +@InternalApi +public class GrpcBigtableStub extends BigtableStub { private static final MethodDescriptor readRowsMethodDescriptor = diff --git a/google-cloud-clients/google-cloud-bigtable/synth.metadata b/google-cloud-clients/google-cloud-bigtable/synth.metadata index 8a59b6903941..4d5d1f5cb053 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.metadata +++ b/google-cloud-clients/google-cloud-bigtable/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-04-29T15:28:19.046154Z", + "updateTime": "2019-04-29T18:25:36.897771Z", "sources": [ { "generator": { diff --git a/google-cloud-clients/google-cloud-bigtable/synth.py b/google-cloud-clients/google-cloud-bigtable/synth.py index 9e50446a2a59..caf9f841ee34 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -49,7 +49,7 @@ def generate_data_api(gapic): ] # Paths are relative to the destination, which is the current working directory - pkg_private = [ + 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", @@ -60,7 +60,7 @@ def generate_data_api(gapic): 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_package_private(pkg_private) + 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') @@ -79,17 +79,14 @@ def generate_admin_api(gapic): ] # Paths are relative to the destination, which is the current working directory - pkg_private = [ + 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/BaseBigtableTableAdminSettings.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/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', @@ -100,7 +97,6 @@ def generate_admin_api(gapic): 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_package_private(pkg_private) make_internal_only(internal_only) java.format_code('../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src') @@ -123,12 +119,4 @@ def make_internal_only(sources): after='/** For internal use only. */\n@InternalApi\n', flags=re.MULTILINE | re.DOTALL) -def make_package_private(sources): - """Strips all toplevel classes' public visibility.""" - s.replace(sources, - before=r'^public (?=.*(?:class|interface) )', - after='', - flags=re.MULTILINE) - - main() From e51783a2e21f7e1478c90d56e9f12e35330cf8f9 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 18:41:56 -0400 Subject: [PATCH 5/7] add todo to simplify synth.py --- google-cloud-clients/google-cloud-bigtable/synth.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google-cloud-clients/google-cloud-bigtable/synth.py b/google-cloud-clients/google-cloud-bigtable/synth.py index caf9f841ee34..123db9af5304 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -19,6 +19,9 @@ import synthtool.gcp as gcp import synthtool.languages.java as java +# TODO: try to move the GAPIC surface hiding to the gapic-generator: +# https://github.com/googleapis/gapic-generator/issues/2742 + def main(): gapic = gcp.GAPICGenerator() From 2c8d0269e5a5958aa063740bbbd83623e987a4f0 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 18:55:04 -0400 Subject: [PATCH 6/7] Add tests to make sure that the gapic api is @InternalOnly --- .../bigtable/admin/v2/HiddenGapicApiTest.java | 66 +++++++++++++++++++ .../bigtable/data/v2/HiddenGapicApiTest.java | 58 ++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/HiddenGapicApiTest.java create mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/HiddenGapicApiTest.java 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..c4962ed0b252 --- /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(); + } +} \ No newline at end of file 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..146b7f6050ba --- /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(); + } +} From 26523235efef4ca9f4a9eb3a6d17346eda5bb31b Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Mon, 29 Apr 2019 18:56:34 -0400 Subject: [PATCH 7/7] Keep @Autogenerated annotations --- .../v2/BaseBigtableInstanceAdminClient.java | 2 ++ .../v2/BaseBigtableInstanceAdminSettings.java | 2 ++ .../v2/BaseBigtableTableAdminClient.java | 2 ++ .../v2/BaseBigtableTableAdminSettings.java | 2 ++ .../v2/stub/BigtableInstanceAdminStub.java | 2 ++ .../admin/v2/stub/BigtableTableAdminStub.java | 2 ++ ...cBigtableInstanceAdminCallableFactory.java | 2 ++ .../stub/GrpcBigtableInstanceAdminStub.java | 2 ++ ...GrpcBigtableTableAdminCallableFactory.java | 2 ++ .../v2/stub/GrpcBigtableTableAdminStub.java | 2 ++ .../bigtable/data/v2/stub/BigtableStub.java | 2 ++ .../data/v2/stub/BigtableStubSettings.java | 2 ++ .../v2/stub/GrpcBigtableCallableFactory.java | 2 ++ .../data/v2/stub/GrpcBigtableStub.java | 2 ++ .../bigtable/admin/v2/HiddenGapicApiTest.java | 22 +++++++++---------- .../bigtable/data/v2/HiddenGapicApiTest.java | 8 +++---- .../google-cloud-bigtable/synth.metadata | 6 ++--- .../google-cloud-bigtable/synth.py | 2 +- 18 files changed, 47 insertions(+), 19 deletions(-) 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 9f8164d03e06..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 @@ -73,9 +73,11 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND SERVICE /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class BaseBigtableInstanceAdminClient implements BackgroundResource { private final BaseBigtableInstanceAdminSettings settings; 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 a5779e8b35ee..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 @@ -65,9 +65,11 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class BaseBigtableInstanceAdminSettings extends ClientSettings { 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 8ef1fae56387..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 @@ -62,9 +62,11 @@ import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND SERVICE /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class BaseBigtableTableAdminClient implements BackgroundResource { private final BaseBigtableTableAdminSettings settings; 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 d9419ebec474..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 @@ -57,9 +57,11 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class BaseBigtableTableAdminSettings extends ClientSettings { /** Returns the object with the settings used for calls to createTable. */ 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 1a3f9c36c3ac..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 @@ -55,9 +55,11 @@ import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public abstract class BigtableInstanceAdminStub implements BackgroundResource { 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 0b003ffe960e..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 @@ -47,9 +47,11 @@ import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public abstract class BigtableTableAdminStub implements BackgroundResource { 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 9fc5cdaf0669..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 @@ -33,9 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory { @Override 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 949b37ce6c2d..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 @@ -66,9 +66,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub { 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 73aaf460c984..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 @@ -33,9 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory { @Override 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 a575a8891304..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 @@ -58,9 +58,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableTableAdminStub extends BigtableTableAdminStub { 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 54174b6269ad..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 @@ -31,9 +31,11 @@ import com.google.bigtable.v2.ReadRowsResponse; import com.google.bigtable.v2.SampleRowKeysRequest; import com.google.bigtable.v2.SampleRowKeysResponse; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public abstract class BigtableStub implements BackgroundResource { 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 6bd7057bee1c..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 @@ -50,10 +50,12 @@ import com.google.common.collect.Lists; import java.io.IOException; import java.util.List; +import javax.annotation.Generated; import org.threeten.bp.Duration; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class BigtableStubSettings extends StubSettings { /** The default scopes of the service. */ 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 02d5f88cbf5e..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 @@ -33,9 +33,11 @@ import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableCallableFactory implements GrpcStubCallableFactory { @Override 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 14d0b1690443..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 @@ -42,9 +42,11 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS /** For internal use only. */ +@Generated("by gapic-generator") @InternalApi public class GrpcBigtableStub extends BigtableStub { 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 index c4962ed0b252..354a725b6e5c 100644 --- 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 @@ -40,16 +40,16 @@ public class HiddenGapicApiTest { @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, + GrpcBigtableInstanceAdminCallableFactory.class, + GrpcBigtableInstanceAdminStub.class, + BaseBigtableInstanceAdminSettings.class, + GrpcBigtableTableAdminCallableFactory.class, + GrpcBigtableTableAdminStub.class, + BaseBigtableTableAdminSettings.class, + BigtableInstanceAdminStub.class, + BigtableTableAdminStub.class, + BaseBigtableInstanceAdminClient.class, + BaseBigtableTableAdminClient.class, }; } @@ -63,4 +63,4 @@ public void test() { .that(testClass.getAnnotation(InternalApi.class)) .isNotNull(); } -} \ No newline at end of file +} 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 index 146b7f6050ba..7c302b7cbd30 100644 --- 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 @@ -38,10 +38,10 @@ public class HiddenGapicApiTest { @Parameters public static Object[] data() { return new Object[] { - BigtableStub.class, - BigtableStubSettings.class, - GrpcBigtableStub.class, - GrpcBigtableCallableFactory.class + BigtableStub.class, + BigtableStubSettings.class, + GrpcBigtableStub.class, + GrpcBigtableCallableFactory.class }; } diff --git a/google-cloud-clients/google-cloud-bigtable/synth.metadata b/google-cloud-clients/google-cloud-bigtable/synth.metadata index 4d5d1f5cb053..8e1fc91babf5 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.metadata +++ b/google-cloud-clients/google-cloud-bigtable/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-04-29T18:25:36.897771Z", + "updateTime": "2019-04-29T22:56:01.195702Z", "sources": [ { "generator": { @@ -12,8 +12,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "808110e242c682d7ac2bab6d9c49fc3bf72d7604", - "internalRef": "245313728" + "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 123db9af5304..0909f5291d95 100644 --- a/google-cloud-clients/google-cloud-bigtable/synth.py +++ b/google-cloud-clients/google-cloud-bigtable/synth.py @@ -119,7 +119,7 @@ def make_internal_only(sources): s.replace(sources, before=r'/\*\*.+?\*/\n(?:^@[^\n]*\n)*(?=public [a-zA-B ]*class)', - after='/** For internal use only. */\n@InternalApi\n', + after='/** For internal use only. */\n@Generated("by gapic-generator")\n@InternalApi\n', flags=re.MULTILINE | re.DOTALL) main()