Example of loading a newline-delimited-json file with textual fields from GCS to a table. + *
{@code
+ * String datasetName = "my_dataset_name";
+ * String tableName = "my_table_name";
+ * String sourceUri = "gs://cloud-samples-data/bigquery/us-states/us-states.json";
+ * TableId tableId = TableId.of(datasetName, tableName);
+ * // Table field definition
+ * Field[] fields = new Field[] {
+ * Field.of("name", LegacySQLTypeName.STRING),
+ * Field.of("post_abbr", LegacySQLTypeName.STRING)
+ * };
+ * // Table schema definition
+ * Schema schema = Schema.of(fields);
+ * LoadJobConfiguration configuration = LoadJobConfiguration.builder(tableId, sourceUri)
+ * .setFormatOptions(FormatOptions.json())
+ * .setCreateDisposition(CreateDisposition.CREATE_IF_NEEDED)
+ * .setSchema(schema)
+ * .build();
+ * // Load the table
+ * Job remoteLoadJob = bigquery.create(JobInfo.of(configuration));
+ * remoteLoadJob = remoteLoadJob.waitFor();
+ * // Check the table
+ * System.out.println("State: " + remoteLoadJob.getStatus().getState());
+ * return ((StandardTableDefinition) bigquery.getTable(tableId).getDefinition()).getNumRows();
+ * }
+ *
* Example of creating a query job. *
{@code
* String query = "SELECT field FROM my_dataset_name.my_table_name";
@@ -861,8 +887,7 @@ public int hashCode() {
* Lists the table's rows.
*
* Example of listing table rows, specifying the page size.
- *
- *
{@code
+ * {@code
* String datasetName = "my_dataset_name";
* String tableName = "my_table_name";
* // This example reads the result 100 rows per RPC call. If there's no need to limit the number,
@@ -882,8 +907,7 @@ public int hashCode() {
* Lists the table's rows.
*
* Example of listing table rows, specifying the page size.
- *
- *
{@code
+ * {@code
* String datasetName = "my_dataset_name";
* String tableName = "my_table_name";
* TableId tableIdObject = TableId.of(datasetName, tableName);
@@ -891,7 +915,7 @@ public int hashCode() {
* // simply omit the option.
* TableResult tableData =
* bigquery.listTableData(tableIdObject, TableDataListOption.pageSize(100));
- * for (FieldValueList row : rowIterator.hasNext()) {
+ * for (FieldValueList row : tableData.iterateAll()) {
* // do something with the row
* }
* }
@@ -904,17 +928,16 @@ public int hashCode() {
* Lists the table's rows. If the {@code schema} is not {@code null}, it is available to the
* {@link FieldValueList} iterated over.
*
- * Example of listing table rows.
- *
- *
{@code
+ * Example of listing table rows with schema.
+ *
{@code
* String datasetName = "my_dataset_name";
* String tableName = "my_table_name";
* Schema schema = ...;
- * String field = "my_field";
+ * String field = "field";
* TableResult tableData =
* bigquery.listTableData(datasetName, tableName, schema);
* for (FieldValueList row : tableData.iterateAll()) {
- * row.get(field)
+ * row.get(field);
* }
* }
*
@@ -927,9 +950,8 @@ TableResult listTableData(
* Lists the table's rows. If the {@code schema} is not {@code null}, it is available to the
* {@link FieldValueList} iterated over.
*
- * Example of listing table rows.
- *
- *
{@code
+ * Example of listing table rows with schema.
+ *
{@code
* Schema schema =
* Schema.of(
* Field.of("word", LegacySQLTypeName.STRING),
@@ -1047,28 +1069,21 @@ TableResult listTableData(
* queries. Since dry-run queries are not actually executed, there's no way to retrieve results.
*
* Example of running a query.
- *
- *
{@code
- * String query = "SELECT distinct(corpus) FROM `bigquery-public-data.samples.shakespeare`";
- * QueryJobConfiguration queryConfig = QueryJobConfiguration.of(query);
- *
- * // To run the legacy syntax queries use the following code instead:
- * // String query = "SELECT unique(corpus) FROM [bigquery-public-data:samples.shakespeare]"
- * // QueryJobConfiguration queryConfig =
- * // QueryJobConfiguration.newBuilder(query).setUseLegacySql(true).build();
- *
+ * {@code
+ * String query = "SELECT unique(corpus) FROM [bigquery-public-data:samples.shakespeare]";
+ * QueryJobConfiguration queryConfig =
+ * QueryJobConfiguration.newBuilder(query).setUseLegacySql(true).build();
* for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
* // do something with the data
* }
* }
*
* Example of running a query with query parameters.
- *
- *
{@code
- * String query =
- * "SELECT distinct(corpus) FROM `bigquery-public-data.samples.shakespeare` where word_count > ?";
+ * {@code
+ * String query = "SELECT distinct(corpus) FROM `bigquery-public-data.samples.shakespeare` where word_count > @wordCount";
+ * // Note, standard SQL is required to use query parameters. Legacy SQL will not work.
* QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query)
- * .addPositionalParameter(QueryParameterValue.int64(5))
+ * .addNamedParameter("wordCount", QueryParameterValue.int64(5))
* .build();
* for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
* // do something with the data
@@ -1092,18 +1107,6 @@ TableResult query(QueryJobConfiguration configuration, JobOption... options)
* See {@link #query(QueryJobConfiguration, JobOption...)} for examples on populating a {@link
* QueryJobConfiguration}.
*
- *
The recommended way to create a randomly generated JobId is the following:
- *
- *
{@code
- * JobId jobId = JobId.of();
- * }
- *
- * For a user specified job id with an optional prefix use the following:
- *
- * {@code
- * JobId jobId = JobId.of("my_prefix-my_unique_job_id");
- * }
- *
* @throws BigQueryException upon failure
* @throws InterruptedException if the current thread gets interrupted while waiting for the query
* to complete
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobId.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobId.java
index 0ca5d571c66b..7d88dc8cc1ac 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobId.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobId.java
@@ -19,89 +19,106 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.api.services.bigquery.model.JobReference;
-
+import com.google.auto.value.AutoValue;
import java.io.Serializable;
-import java.util.Objects;
import java.util.UUID;
+import javax.annotation.Nullable;
-/**
- * Google BigQuery Job identity.
- */
-public final class JobId implements Serializable {
-
- private static final long serialVersionUID = 1225914835379688976L;
+/** Google BigQuery Job identity. */
+@AutoValue
+public abstract class JobId implements Serializable {
- private final String project;
- private final String job;
+ private static final long serialVersionUID = 1225914835379688977L;
+ JobId() {
+ // Users cannot extend this, but AutoValue can.
+ }
/**
- * Returns project's user-defined id.
+ * Returns job's project id.
+ *
+ * When sending requests with null project, the client will attempt to infer the project name
+ * from the environment.
*/
- public String getProject() {
- return project;
- }
+ @Nullable
+ public abstract String getProject();
+ /**
+ * Returns the job's id.
+ *
+ *
The server returns null job id for dry-run queries.
+ */
+ @Nullable
+ public abstract String getJob();
/**
- * Returns the job's user-defined id.
+ * Returns the job's location.
+ *
+ *
When sending requests, the location must be specified for jobs whose location not "US" or
+ * "EU".
*/
- public String getJob() {
- return job;
+ @Nullable
+ abstract String getLocation();
+
+ public abstract Builder toBuilder();
+
+ public static Builder newBuilder() {
+ return new AutoValue_JobId.Builder();
}
- private JobId(String project, String job) {
- this.project = project;
- this.job = job;
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder setProject(String project);
+
+ public abstract Builder setJob(String job);
+
+ /** {@code setJob} to a pseudo-random string. */
+ public Builder setRandomJob() {
+ return setJob(UUID.randomUUID().toString());
+ }
+
+ abstract Builder setLocation(String location);
+
+ public abstract JobId build();
}
/**
* Creates a job identity given project's and job's user-defined id.
*/
public static JobId of(String project, String job) {
- return new JobId(checkNotNull(project), checkNotNull(job));
+ return newBuilder().setProject(checkNotNull(project)).setJob(checkNotNull(job)).build();
}
/**
* Creates a job identity given only its user-defined id.
*/
public static JobId of(String job) {
- return new JobId(null, checkNotNull(job));
+ return newBuilder().setJob(checkNotNull(job)).build();
}
/**
* Creates a job identity with autogenerated id and no project specified.
*/
public static JobId of() {
- return new JobId(null, UUID.randomUUID().toString());
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj == this
- || obj instanceof JobId
- && Objects.equals(toPb(), ((JobId) obj).toPb());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(project, job);
- }
-
- @Override
- public String toString() {
- return toPb().toString();
+ return newBuilder().setRandomJob().build();
}
JobId setProjectId(String projectId) {
- return getProject() != null ? this : JobId.of(projectId, getJob());
+ return getProject() != null ? this : toBuilder().setProject(projectId).build();
}
JobReference toPb() {
- return new JobReference().setProjectId(project).setJobId(job);
+ return new JobReference()
+ .setProjectId(getProject())
+ .setJobId(getJob())
+ .setLocation(getLocation());
}
static JobId fromPb(JobReference jobRef) {
- return new JobId(jobRef.getProjectId(), jobRef.getJobId());
+ return newBuilder()
+ .setProject(jobRef.getProjectId())
+ .setJob(jobRef.getJobId())
+ .setLocation(jobRef.getLocation())
+ .build();
}
}
diff --git a/google-cloud-bigquerydatatransfer/README.md b/google-cloud-bigquerydatatransfer/README.md
index c7813669d0ef..db12e48a8cee 100644
--- a/google-cloud-bigquerydatatransfer/README.md
+++ b/google-cloud-bigquerydatatransfer/README.md
@@ -25,16 +25,16 @@ Add this to your pom.xml file
com.google.cloud
google-cloud-bigquerydatatransfer
- 0.38.0-beta
+ 0.43.0-beta
```
If you are using Gradle, add this to your dependencies
```Groovy
-compile 'com.google.cloud:google-cloud-bigquerydatatransfer:0.38.0-beta'
+compile 'com.google.cloud:google-cloud-bigquerydatatransfer:0.43.0-beta'
```
If you are using SBT, add this to your dependencies
```Scala
-libraryDependencies += "com.google.cloud" % "google-cloud-bigquerydatatransfer" % "0.38.0-beta"
+libraryDependencies += "com.google.cloud" % "google-cloud-bigquerydatatransfer" % "0.43.0-beta"
```
[//]: # ({x-version-update-end})
diff --git a/google-cloud-bigquerydatatransfer/pom.xml b/google-cloud-bigquerydatatransfer/pom.xml
index 849324840592..cb423a1148d7 100644
--- a/google-cloud-bigquerydatatransfer/pom.xml
+++ b/google-cloud-bigquerydatatransfer/pom.xml
@@ -2,7 +2,7 @@
4.0.0
google-cloud-bigquerydatatransfer
- 0.38.1-beta-SNAPSHOT
+ 0.43.1-beta-SNAPSHOT
jar
Google Cloud Bigquery Data Transfer
https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-bigquerydatatransfer
@@ -12,7 +12,7 @@
com.google.cloud
google-cloud-pom
- 0.38.1-alpha-SNAPSHOT
+ 0.43.1-alpha-SNAPSHOT
google-cloud-bigquerydatatransfer
diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java
index ac89036b8dda..84d13ea60c10 100644
--- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java
+++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java
@@ -58,7 +58,7 @@
*
* DataTransferServiceSettings.Builder dataTransferServiceSettingsBuilder =
* DataTransferServiceSettings.newBuilder();
- * dataTransferServiceSettingsBuilder.getDataSourceSettings().getRetrySettingsBuilder()
+ * dataTransferServiceSettingsBuilder.getDataSourceSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* DataTransferServiceSettings dataTransferServiceSettings = dataTransferServiceSettingsBuilder.build();
*
diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java
index 86d72ae109b2..1221d16238ca 100644
--- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java
+++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java
@@ -96,7 +96,7 @@
*
* DataTransferServiceStubSettings.Builder dataTransferServiceSettingsBuilder =
* DataTransferServiceStubSettings.newBuilder();
- * dataTransferServiceSettingsBuilder.getDataSourceSettings().getRetrySettingsBuilder()
+ * dataTransferServiceSettingsBuilder.getDataSourceSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* DataTransferServiceStubSettings dataTransferServiceSettings = dataTransferServiceSettingsBuilder.build();
*
diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceCallableFactory.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceCallableFactory.java
new file mode 100644
index 000000000000..758ef1a94644
--- /dev/null
+++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceCallableFactory.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.bigquery.datatransfer.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC callable factory implementation for BigQuery Data Transfer API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by GAPIC v0.0.5")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcDataTransferServiceCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java
index 3fa4109c1507..cd72c1dc8f24 100644
--- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java
+++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java
@@ -24,7 +24,7 @@
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
-import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.bigquery.datatransfer.v1.CheckValidCredsRequest;
@@ -235,6 +235,8 @@ public class GrpcDataTransferServiceStub extends DataTransferServiceStub {
private final UnaryCallable
checkValidCredsCallable;
+ private final GrpcStubCallableFactory callableFactory;
+
public static final GrpcDataTransferServiceStub create(DataTransferServiceStubSettings settings)
throws IOException {
return new GrpcDataTransferServiceStub(settings, ClientContext.create(settings));
@@ -246,6 +248,12 @@ public static final GrpcDataTransferServiceStub create(ClientContext clientConte
DataTransferServiceStubSettings.newBuilder().build(), clientContext);
}
+ public static final GrpcDataTransferServiceStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcDataTransferServiceStub(
+ DataTransferServiceStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
/**
* Constructs an instance of GrpcDataTransferServiceStub, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
@@ -253,6 +261,20 @@ public static final GrpcDataTransferServiceStub create(ClientContext clientConte
*/
protected GrpcDataTransferServiceStub(
DataTransferServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new GrpcDataTransferServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcDataTransferServiceStub, 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 GrpcDataTransferServiceStub(
+ DataTransferServiceStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
GrpcCallSettings getDataSourceTransportSettings =
GrpcCallSettings.newBuilder()
@@ -316,71 +338,71 @@ protected GrpcDataTransferServiceStub(
.build();
this.getDataSourceCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getDataSourceTransportSettings, settings.getDataSourceSettings(), clientContext);
this.listDataSourcesCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listDataSourcesTransportSettings, settings.listDataSourcesSettings(), clientContext);
this.listDataSourcesPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listDataSourcesTransportSettings, settings.listDataSourcesSettings(), clientContext);
this.createTransferConfigCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createTransferConfigTransportSettings,
settings.createTransferConfigSettings(),
clientContext);
this.updateTransferConfigCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
updateTransferConfigTransportSettings,
settings.updateTransferConfigSettings(),
clientContext);
this.deleteTransferConfigCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteTransferConfigTransportSettings,
settings.deleteTransferConfigSettings(),
clientContext);
this.getTransferConfigCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getTransferConfigTransportSettings,
settings.getTransferConfigSettings(),
clientContext);
this.listTransferConfigsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listTransferConfigsTransportSettings,
settings.listTransferConfigsSettings(),
clientContext);
this.listTransferConfigsPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listTransferConfigsTransportSettings,
settings.listTransferConfigsSettings(),
clientContext);
this.scheduleTransferRunsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
scheduleTransferRunsTransportSettings,
settings.scheduleTransferRunsSettings(),
clientContext);
this.getTransferRunCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getTransferRunTransportSettings, settings.getTransferRunSettings(), clientContext);
this.deleteTransferRunCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteTransferRunTransportSettings,
settings.deleteTransferRunSettings(),
clientContext);
this.listTransferRunsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listTransferRunsTransportSettings, settings.listTransferRunsSettings(), clientContext);
this.listTransferRunsPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listTransferRunsTransportSettings, settings.listTransferRunsSettings(), clientContext);
this.listTransferLogsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listTransferLogsTransportSettings, settings.listTransferLogsSettings(), clientContext);
this.listTransferLogsPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listTransferLogsTransportSettings, settings.listTransferLogsSettings(), clientContext);
this.checkValidCredsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
checkValidCredsTransportSettings, settings.checkValidCredsSettings(), clientContext);
backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
diff --git a/google-cloud-bigquerydatatransfer/src/test/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSmokeTest.java b/google-cloud-bigquerydatatransfer/src/test/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSmokeTest.java
new file mode 100644
index 000000000000..15b439b9cf7b
--- /dev/null
+++ b/google-cloud-bigquerydatatransfer/src/test/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSmokeTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.bigquery.datatransfer.v1;
+
+import static com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListDataSourcesPagedResponse;
+
+import com.google.common.base.Preconditions;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.Test;
+
+@javax.annotation.Generated("by GAPIC")
+public class DataTransferServiceSmokeTest {
+ private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT";
+ private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT";
+
+ @Test
+ public void run() {
+ main(null);
+ }
+
+ public static void main(String args[]) {
+ Logger.getLogger("").setLevel(Level.WARNING);
+ try {
+ executeNoCatch(getProjectId());
+ System.out.println("OK");
+ } catch (Exception e) {
+ System.err.println("Failed with exception:");
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+ public static void executeNoCatch(String projectId) throws Exception {
+ try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
+ ParentName parent = ProjectName.of(projectId);
+
+ ListDataSourcesPagedResponse pagedResponse = client.listDataSources(parent);
+ }
+ }
+
+ private static String getProjectId() {
+ String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME));
+ if (projectId == null) {
+ projectId =
+ System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME));
+ }
+ Preconditions.checkArgument(projectId != null, "A project ID is required.");
+ return projectId;
+ }
+}
diff --git a/google-cloud-bigtable/DEVELOPING.md b/google-cloud-bigtable/DEVELOPING.md
index 2f20ea31ef1c..3c59561ac646 100644
--- a/google-cloud-bigtable/DEVELOPING.md
+++ b/google-cloud-bigtable/DEVELOPING.md
@@ -43,7 +43,7 @@ by constraining the api, the surface api can be made more ergonomic:
* stub/EnhancedBigtableStub: wraps the autogenerated GrpcBigtableStub. It layers logical structure
on top of the protocol level requests and responses. It is responsible for adapting ReadRows
chunks to logical rows and for converting between raw protobufs and user facing wrappers.
-* wrappers/: contains user facing wrappers for the protobufs. Each wrapper has a toProto method
+* models/: contains user facing wrappers for the protobufs. Each wrapper has a toProto method
that will return the corresponding proto.
* internal/: contains internal implementation details. The end user doesn't directly interact with
these classes. It contains things like RequestContext, that is used by all toProto methods to
diff --git a/google-cloud-bigtable/README.md b/google-cloud-bigtable/README.md
new file mode 100644
index 000000000000..beb2a4823d44
--- /dev/null
+++ b/google-cloud-bigtable/README.md
@@ -0,0 +1,174 @@
+# Google Cloud Java Client for Bigtable
+
+Java idiomatic client for [Cloud Bigtable][cloud-bigtable]. Please note that this client is under
+heavy development and is not ready for production use. Please continue to use the
+[HBase API client](https://github.com/GoogleCloudPlatform/cloud-bigtable-client) for production.
+
+[[](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-java/tree/master)
+[](https://coveralls.io/r/GoogleCloudPlatform/google-cloud-java?branch=master)
+[](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable.svg)
+[](https://www.codacy.com/app/mziccard/google-cloud-java)
+[](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772)
+
+- [Product Documentation][bigtable-product-docs]
+- [Client Library Documentation][bigtable-client-lib-docs]
+
+> Note: This client is under heavy development and should not be used in production.
+
+## Quickstart
+
+[//]: # ({x-version-update-start:google-cloud-bigtable:released})
+If you are using Maven, add this to your pom.xml file
+```xml
+
+ com.google.cloud
+ google-cloud-bigtable
+ 0.43.0-alpha
+
+```
+If you are using Gradle, add this to your dependencies
+```Groovy
+compile 'com.google.cloud:google-cloud-bigtable:0.43.0-alpha'
+```
+If you are using SBT, add this to your dependencies
+```Scala
+libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "0.43.0-alpha"
+```
+[//]: # ({x-version-update-end})
+
+## Authentication
+
+See the
+[Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication)
+section in the base directory's README.
+
+## About Cloud Bigtable
+
+[Cloud Bigtable][cloud-bigtable] Cloud Bigtable is Google's NoSQL Big Data database service. It's
+the same database that powers many core Google services, including Search, Analytics, Maps, and
+Gmail.
+
+Be sure to activate the Cloud Bigtable API and the Cloud Bigtable Admin API on the Developer's
+Console to use Cloud Bigtable from your project.
+
+See the [Bigtable client lib docs][bigtable-client-lib-docs] to learn how to
+interact with Cloud Bigtable using this Client Library.
+
+## Getting Started
+#### Prerequisites
+For this tutorial, you will need a
+[Google Developers Console](https://console.developers.google.com/) project with the Cloud Bigtable
+API enabled. You will need to
+[enable billing](https://support.google.com/cloud/answer/6158867?hl=en) to use Google Cloud Bigtable.
+[Follow these instructions](https://cloud.google.com/docs/authentication#preparation) to get your
+project set up. You will also need to set up the local development environment by [installing the
+Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line:
+`gcloud auth login`.
+
+#### Calling Cloud Bigtable
+
+The Cloud Bigtable API is split into 3 parts: Data API, Instance Admin API and Table Admin API.
+
+Here is a code snippet showing simple usage of the Data API. Add the following imports
+at the top of your file:
+
+```java
+import com.google.cloud.bigtable.data.v2.BigtableDataClient;
+import com.google.cloud.bigtable.data.v2.models.InstanceName;
+import com.google.cloud.bigtable.data.v2.models.Query;
+import com.google.cloud.bigtable.data.v2.models.Row;
+
+```
+
+Then, to make a query to Bigtable, use the following code:
+```java
+// Instantiates a client
+String projectId = "my-instance";
+String instanceId = "my-database";
+String tableId = "my-table";
+
+// Create the client
+BigtableDataClient dataClient = BigtableDataClient.create(
+ InstanceName.of(projectId, instanceId));
+
+try {
+ // Query a table
+ Query query = Query.create(tableId)
+ .range("a", "z")
+ .limit(26);
+
+ for (Row row : dataClient.readRows(query)) {
+ System.out.println(row.getKey());
+ }
+} finally {
+ dataClient.close();
+}
+```
+
+The Admin APIs are similar. Here is a code snippet showing how to create a table. Add the following
+imports at the top of your file:
+
+```java
+import com.google.bigtable.admin.v2.ColumnFamily;
+import com.google.bigtable.admin.v2.InstanceName;
+import com.google.bigtable.admin.v2.Table;
+import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
+```
+
+Then, to create a table, use the following code:
+```java
+String projectId = "my-instance";
+String instanceId = "my-database";
+
+BigtableTableAdminClient tableAdminClient = BigtableTableAdminClient.create();
+
+try {
+ tableAdminClient.createTable(
+ InstanceName.of(projectId, instanceId),
+ "new-table-id",
+ Table.newBuilder()
+ .putColumnFamilies("my-family", ColumnFamily.getDefaultInstance())
+ .build()
+ );
+} finally {
+ tableAdminClient.close();
+}
+```
+
+## Troubleshooting
+
+To get help, follow the instructions in the [shared Troubleshooting
+document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
+
+Transport
+---------
+Bigtable uses gRPC for the transport layer.
+
+## Java Versions
+
+Java 7 or above is required for using this client.
+
+## Versioning
+
+This library follows [Semantic Versioning](http://semver.org/).
+
+It is currently in major version zero (`0.y.z`), which means that anything may
+change at any time and the public API should not be considered stable.
+
+## Contributing
+
+Contributions to this library are always welcome and highly encouraged.
+
+See [CONTRIBUTING] for more information on how to get started and [DEVELOPING] for a layout of the
+codebase.
+
+## License
+
+Apache 2.0 - See [LICENSE] for more information.
+
+[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md
+[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE
+[cloud-platform]: https://cloud.google.com/
+[cloud-bigtable]: https://cloud.google.com/bigtable/
+[bigtable-product-docs]: https://cloud.google.com/bigtable/docs/
+[bigtable-client-lib-docs]: https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/index.html?com/google/cloud/bigtable/package-summary.html
diff --git a/google-cloud-bigtable/autogen_files.lst b/google-cloud-bigtable/autogen_files.lst
index 3fa294ad3c58..ef763544fed7 100644
--- a/google-cloud-bigtable/autogen_files.lst
+++ b/google-cloud-bigtable/autogen_files.lst
@@ -1,26 +1,26 @@
-src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java
-src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java
src/test/java/com/google/cloud/bigtable/data/v2/MockBigtableImpl.java
-src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java
+src/test/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClientTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/MockBigtable.java
+src/main/java/com/google/cloud/bigtable/data/v2/package-info.java
src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java
-src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java
-src/main/java/com/google/cloud/bigtable/data/v2/package-info.java
-src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableInstanceAdminImpl.java
-src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableInstanceAdmin.java
-src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableTableAdminImpl.java
-src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java
-src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java
+src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java
src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableTableAdmin.java
+src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTest.java
+src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java
+src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableTableAdminImpl.java
+src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableInstanceAdmin.java
+src/test/java/com/google/cloud/bigtable/admin/v2/MockBigtableInstanceAdminImpl.java
+src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java
src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
-src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
-src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java
src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java
-src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java
-src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java
src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java
+src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java
src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java
-src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java
+src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java
+src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java
src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java
-src/main/java/com/google/cloud/bigtable/admin/v2/package-info.java
+src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
+src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java
diff --git a/google-cloud-bigtable/handwritten_files.lst b/google-cloud-bigtable/handwritten_files.lst
index 7549a50a2469..acf082236813 100644
--- a/google-cloud-bigtable/handwritten_files.lst
+++ b/google-cloud-bigtable/handwritten_files.lst
@@ -1,49 +1,76 @@
src/test/resources/com/google/cloud/bigtable/data/v2/stub/readrows/read-rows-acceptance-test.json
-src/test/java/com/google/cloud/bigtable/gaxx/.DS_Store
src/test/java/com/google/cloud/bigtable/gaxx/reframing/ReframingResponseObserverTest.java
-src/test/java/com/google/cloud/bigtable/gaxx/testing/FakeStreamingApi.java
src/test/java/com/google/cloud/bigtable/gaxx/testing/FakeStatusCode.java
-src/test/java/com/google/cloud/bigtable/gaxx/testing/MockStreamingApi.java
src/test/java/com/google/cloud/bigtable/gaxx/testing/package-info.java
-src/test/java/com/google/cloud/bigtable/data/v2/internal/RegexUtilTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/internal/ByteStringComparatorTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/MutationTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/FiltersTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/RowMutationTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/QueryTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/RangeTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/RowTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultRowAdapterTest.java
-src/test/java/com/google/cloud/bigtable/data/v2/BigtableDataClientTest.java
+src/test/java/com/google/cloud/bigtable/gaxx/testing/MockStreamingApi.java
+src/test/java/com/google/cloud/bigtable/gaxx/testing/FakeStreamingApi.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/CheckAndMutateRowCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/BulkMutateRowsRetryTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/SampleRowKeysCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/MutateRowCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsRetryTest.java
src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/RowMergingCallableTest.java
src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsMergingAcceptanceTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsUserCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/FilterMarkerRowsCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsFirstCallableTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/stub/ReadModifyWriteRowCallableTest.java
src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/BigtableDataClientTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/FiltersTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultRowAdapterTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/QueryTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/ConditionalRowMutationTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/ReadModifyWriteRowTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/MutationTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/RowTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/RowMutationTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/models/RangeTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/internal/RegexUtilTest.java
+src/test/java/com/google/cloud/bigtable/data/v2/internal/ByteStringComparatorTest.java
+src/main/java/com/google/cloud/bigtable/gaxx/package-info.java
+src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java
src/main/java/com/google/cloud/bigtable/gaxx/reframing/IncompleteStreamException.java
src/main/java/com/google/cloud/bigtable/gaxx/reframing/ReframingResponseObserver.java
src/main/java/com/google/cloud/bigtable/gaxx/reframing/Reframer.java
-src/main/java/com/google/cloud/bigtable/gaxx/reframing/package-info.java
-src/main/java/com/google/cloud/bigtable/gaxx/package-info.java
-src/main/java/com/google/cloud/bigtable/data/.DS_Store
-src/main/java/com/google/cloud/bigtable/data/v2/.DS_Store
-src/main/java/com/google/cloud/bigtable/data/v2/internal/ByteStringComparator.java
-src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java
-src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/MutationApi.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Mutation.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/RowAdapter.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultRowAdapter.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Filters.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Row.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Validations.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/KeyOffset.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Query.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/RowCell.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/Range.java
-src/main/java/com/google/cloud/bigtable/data/v2/models/RowMutation.java
src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
+src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/CheckAndMutateRowCallable.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsUserFacingCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/package-info.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsSpoolingCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/RowMergingCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/package-info.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsFirstCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsResumptionStrategy.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/RowMerger.java
src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/StateMachine.java
-src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java
-src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsRetryCompletedCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsUserCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/readrows/FilterMarkerRowsCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/SampleRowKeysCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/MutateRowCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/stub/ReadModifyWriteRowCallable.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/ReadModifyWriteRow.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/RowCell.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Validations.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/RowMutation.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/BulkMutationBatcher.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Mutation.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultRowAdapter.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/RowAdapter.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/KeyOffset.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Range.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/ConditionalRowMutation.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Filters.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/MutationApi.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Row.java
+src/main/java/com/google/cloud/bigtable/data/v2/models/Query.java
+src/main/java/com/google/cloud/bigtable/data/v2/internal/ByteStringComparator.java
+src/main/java/com/google/cloud/bigtable/data/v2/internal/DummyBatchingDescriptor.java
+src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java
+src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java
diff --git a/google-cloud-bigtable/pom.xml b/google-cloud-bigtable/pom.xml
index 94422b725c1a..3ae99eaf00ed 100644
--- a/google-cloud-bigtable/pom.xml
+++ b/google-cloud-bigtable/pom.xml
@@ -2,7 +2,7 @@
4.0.0
google-cloud-bigtable
- 0.38.1-alpha-SNAPSHOT
+ 0.43.1-alpha-SNAPSHOT
jar
Google Cloud Bigtable
https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-bigtable
@@ -12,7 +12,7 @@
com.google.cloud
google-cloud-pom
- 0.38.1-alpha-SNAPSHOT
+ 0.43.1-alpha-SNAPSHOT
google-cloud-bigtable
@@ -127,6 +127,24 @@
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.19.1
+
+
+
+ integration-test
+ verify
+
+
+
+
+ classes
+ true
+ 2
+
+
org.apache.maven.plugins
maven-javadoc-plugin
diff --git a/google-cloud-bigtable/scripts/setup-test-table.sh b/google-cloud-bigtable/scripts/setup-test-table.sh
new file mode 100755
index 000000000000..1ebedb0f6007
--- /dev/null
+++ b/google-cloud-bigtable/scripts/setup-test-table.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+# Set up a table to use for integration tests.
+
+set -x
+
+# Format: projects//instances//tables/
+TABLE_NAME=$1
+
+if [[ ${TABLE_NAME} =~ projects\/([^/]+)\/instances\/([^/]+)\/tables\/([^/]+) ]]; then
+ PROJECT_ID=${BASH_REMATCH[1]}
+ INSTANCE_ID=${BASH_REMATCH[2]}
+ TABLE_ID=${BASH_REMATCH[3]}
+else
+ echo "Invalid table name: $TABLE_NAME" 1>&2
+ exit 1
+fi
+
+cbt -project $PROJECT_ID -instance $INSTANCE_ID createtable $TABLE_ID
+cbt -project $PROJECT_ID -instance $INSTANCE_ID createfamily $TABLE_ID cf
+cbt -project $PROJECT_ID -instance $INSTANCE_ID setgcpolicy $TABLE_ID cf maxversions=1
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
index 10d5166d050c..c26b67906cb3 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettings.java
@@ -86,7 +86,7 @@
*
* BigtableInstanceAdminSettings.Builder bigtableInstanceAdminSettingsBuilder =
* BigtableInstanceAdminSettings.newBuilder();
- * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettingsBuilder()
+ * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* BigtableInstanceAdminSettings bigtableInstanceAdminSettings = bigtableInstanceAdminSettingsBuilder.build();
*
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java
index d7191798cffb..88c154f2b216 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java
@@ -338,7 +338,7 @@ public final UnaryCallable createTableCallable() {
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
* String tableId = "";
- * String sourceSnapshot = "";
+ * SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
* }
*
@@ -353,13 +353,13 @@ public final UnaryCallable createTableCallable() {
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createTableFromSnapshotAsync(
- InstanceName parent, String tableId, String sourceSnapshot) {
+ InstanceName parent, String tableId, SnapshotName sourceSnapshot) {
CreateTableFromSnapshotRequest request =
CreateTableFromSnapshotRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setTableId(tableId)
- .setSourceSnapshot(sourceSnapshot)
+ .setSourceSnapshot(sourceSnapshot == null ? null : sourceSnapshot.toString())
.build();
return createTableFromSnapshotAsync(request);
}
@@ -380,8 +380,8 @@ public final OperationFuture createTable
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
* String tableId = "";
- * String sourceSnapshot = "";
- * Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(parent.toString(), tableId, sourceSnapshot).get();
+ * SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+ * Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(parent.toString(), tableId, sourceSnapshot.toString()).get();
* }
*
*
@@ -422,11 +422,11 @@ public final OperationFuture createTable
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
* String tableId = "";
- * String sourceSnapshot = "";
+ * SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
* .setParent(parent.toString())
* .setTableId(tableId)
- * .setSourceSnapshot(sourceSnapshot)
+ * .setSourceSnapshot(sourceSnapshot.toString())
* .build();
* Table response = bigtableTableAdminClient.createTableFromSnapshotAsync(request).get();
* }
@@ -456,11 +456,11 @@ public final OperationFuture createTable
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
* String tableId = "";
- * String sourceSnapshot = "";
+ * SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
* .setParent(parent.toString())
* .setTableId(tableId)
- * .setSourceSnapshot(sourceSnapshot)
+ * .setSourceSnapshot(sourceSnapshot.toString())
* .build();
* OperationFuture<Operation> future = bigtableTableAdminClient.createTableFromSnapshotOperationCallable().futureCall(request);
* // Do something
@@ -490,11 +490,11 @@ public final OperationFuture createTable
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
* String tableId = "";
- * String sourceSnapshot = "";
+ * SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder()
* .setParent(parent.toString())
* .setTableId(tableId)
- * .setSourceSnapshot(sourceSnapshot)
+ * .setSourceSnapshot(sourceSnapshot.toString())
* .build();
* ApiFuture<Operation> future = bigtableTableAdminClient.createTableFromSnapshotCallable().futureCall(request);
* // Do something
@@ -1260,13 +1260,103 @@ public final CheckConsistencyResponse checkConsistency(CheckConsistencyRequest r
*
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
- * String cluster = "";
- * String snapshotId = "";
+ * ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+ * SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+ * String description = "";
+ * Snapshot response = bigtableTableAdminClient.snapshotTableAsync(name, cluster, snapshotId, description).get();
+ * }
+ *
+ *
+ * @param name The unique name of the table to have the snapshot taken. Values are of the form
+ * `projects/<project>/instances/<instance>/tables/<table>`.
+ * @param cluster The name of the cluster where the snapshot will be created in. Values are of the
+ * form `projects/<project>/instances/<instance>/clusters/<cluster>`.
+ * @param snapshotId The ID by which the new snapshot should be referred to within the parent
+ * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than
+ * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`.
+ * @param description Description of the snapshot.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture snapshotTableAsync(
+ TableName name, ClusterName cluster, SnapshotName snapshotId, String description) {
+
+ SnapshotTableRequest request =
+ SnapshotTableRequest.newBuilder()
+ .setName(name == null ? null : name.toString())
+ .setCluster(cluster == null ? null : cluster.toString())
+ .setSnapshotId(snapshotId == null ? null : snapshotId.toString())
+ .setDescription(description)
+ .build();
+ return snapshotTableAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * This is a private alpha release of Cloud Bigtable snapshots. This feature is not currently
+ * available to most Cloud Bigtable customers. This feature might be changed in
+ * backward-incompatible ways and is not recommended for production use. It is not subject to any
+ * SLA or deprecation policy.
+ *
+ * Creates a new snapshot in the specified cluster from the specified source table. The cluster
+ * and the table must be in the same instance.
+ *
+ *
Sample code:
+ *
+ *
+ * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
+ * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+ * ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+ * SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
+ * String description = "";
+ * Snapshot response = bigtableTableAdminClient.snapshotTableAsync(name.toString(), cluster.toString(), snapshotId.toString(), description).get();
+ * }
+ *
+ *
+ * @param name The unique name of the table to have the snapshot taken. Values are of the form
+ * `projects/<project>/instances/<instance>/tables/<table>`.
+ * @param cluster The name of the cluster where the snapshot will be created in. Values are of the
+ * form `projects/<project>/instances/<instance>/clusters/<cluster>`.
+ * @param snapshotId The ID by which the new snapshot should be referred to within the parent
+ * cluster, e.g., `mysnapshot` of the form: `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than
+ * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/mysnapshot`.
+ * @param description Description of the snapshot.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture snapshotTableAsync(
+ String name, String cluster, String snapshotId, String description) {
+
+ SnapshotTableRequest request =
+ SnapshotTableRequest.newBuilder()
+ .setName(name)
+ .setCluster(cluster)
+ .setSnapshotId(snapshotId)
+ .setDescription(description)
+ .build();
+ return snapshotTableAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * This is a private alpha release of Cloud Bigtable snapshots. This feature is not currently
+ * available to most Cloud Bigtable customers. This feature might be changed in
+ * backward-incompatible ways and is not recommended for production use. It is not subject to any
+ * SLA or deprecation policy.
+ *
+ * Creates a new snapshot in the specified cluster from the specified source table. The cluster
+ * and the table must be in the same instance.
+ *
+ *
Sample code:
+ *
+ *
+ * try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
+ * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
+ * ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+ * SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* String description = "";
* SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
* .setName(name.toString())
- * .setCluster(cluster)
- * .setSnapshotId(snapshotId)
+ * .setCluster(cluster.toString())
+ * .setSnapshotId(snapshotId.toString())
* .setDescription(description)
* .build();
* Snapshot response = bigtableTableAdminClient.snapshotTableAsync(request).get();
@@ -1296,13 +1386,13 @@ public final OperationFuture snapshotTableAsync
*
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
- * String cluster = "";
- * String snapshotId = "";
+ * ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+ * SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* String description = "";
* SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
* .setName(name.toString())
- * .setCluster(cluster)
- * .setSnapshotId(snapshotId)
+ * .setCluster(cluster.toString())
+ * .setSnapshotId(snapshotId.toString())
* .setDescription(description)
* .build();
* OperationFuture<Operation> future = bigtableTableAdminClient.snapshotTableOperationCallable().futureCall(request);
@@ -1331,13 +1421,13 @@ public final OperationFuture snapshotTableAsync
*
* try (BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.create()) {
* TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
- * String cluster = "";
- * String snapshotId = "";
+ * ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
+ * SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* String description = "";
* SnapshotTableRequest request = SnapshotTableRequest.newBuilder()
* .setName(name.toString())
- * .setCluster(cluster)
- * .setSnapshotId(snapshotId)
+ * .setCluster(cluster.toString())
+ * .setSnapshotId(snapshotId.toString())
* .setDescription(description)
* .build();
* ApiFuture<Operation> future = bigtableTableAdminClient.snapshotTableCallable().futureCall(request);
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
index 7449b96c6327..33503291d325 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
@@ -78,7 +78,7 @@
*
* BigtableTableAdminSettings.Builder bigtableTableAdminSettingsBuilder =
* BigtableTableAdminSettings.newBuilder();
- * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettingsBuilder()
+ * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* BigtableTableAdminSettings bigtableTableAdminSettings = bigtableTableAdminSettingsBuilder.build();
*
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java
index 53825d6d0cec..c3278d00d99a 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStubSettings.java
@@ -104,7 +104,7 @@
*
* BigtableInstanceAdminStubSettings.Builder bigtableInstanceAdminSettingsBuilder =
* BigtableInstanceAdminStubSettings.newBuilder();
- * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettingsBuilder()
+ * bigtableInstanceAdminSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* BigtableInstanceAdminStubSettings bigtableInstanceAdminSettings = bigtableInstanceAdminSettingsBuilder.build();
*
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java
index 297ccc5020f6..9d0c607fadc2 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStubSettings.java
@@ -96,7 +96,7 @@
*
* BigtableTableAdminStubSettings.Builder bigtableTableAdminSettingsBuilder =
* BigtableTableAdminStubSettings.newBuilder();
- * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettingsBuilder()
+ * bigtableTableAdminSettingsBuilder.createTableSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* BigtableTableAdminStubSettings bigtableTableAdminSettings = bigtableTableAdminSettingsBuilder.build();
*
@@ -594,7 +594,7 @@ private static Builder initDefaults(Builder builder) {
builder
.checkConsistencySettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
builder
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java
new file mode 100644
index 000000000000..fa9c6f4adf1d
--- /dev/null
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.bigtable.admin.v2.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+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 v0.0.5")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcBigtableInstanceAdminCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java
index b00c2ca06246..d23e548f3c8b 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java
@@ -21,9 +21,10 @@
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
-import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.bigtable.admin.v2.AppProfile;
import com.google.bigtable.admin.v2.Cluster;
@@ -50,6 +51,7 @@
import com.google.bigtable.admin.v2.UpdateAppProfileRequest;
import com.google.bigtable.admin.v2.UpdateClusterMetadata;
import com.google.bigtable.admin.v2.UpdateInstanceMetadata;
+import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
@@ -61,6 +63,7 @@
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
@@ -267,6 +270,8 @@ public class GrpcBigtableInstanceAdminStub extends BigtableInstanceAdminStub {
private final UnaryCallable
testIamPermissionsCallable;
+ private final GrpcStubCallableFactory callableFactory;
+
public static final GrpcBigtableInstanceAdminStub create(
BigtableInstanceAdminStubSettings settings) throws IOException {
return new GrpcBigtableInstanceAdminStub(settings, ClientContext.create(settings));
@@ -278,6 +283,12 @@ public static final GrpcBigtableInstanceAdminStub create(ClientContext clientCon
BigtableInstanceAdminStubSettings.newBuilder().build(), clientContext);
}
+ public static final GrpcBigtableInstanceAdminStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcBigtableInstanceAdminStub(
+ BigtableInstanceAdminStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
/**
* Constructs an instance of GrpcBigtableInstanceAdminStub, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
@@ -285,172 +296,350 @@ public static final GrpcBigtableInstanceAdminStub create(ClientContext clientCon
*/
protected GrpcBigtableInstanceAdminStub(
BigtableInstanceAdminStubSettings settings, ClientContext clientContext) throws IOException {
- this.operationsStub = GrpcOperationsStub.create(clientContext);
+ this(settings, clientContext, new GrpcBigtableInstanceAdminCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcBigtableInstanceAdminStub, 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 GrpcBigtableInstanceAdminStub(
+ BigtableInstanceAdminStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings createInstanceTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createInstanceMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateInstanceRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getInstanceTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getInstanceMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetInstanceRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings listInstancesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listInstancesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListInstancesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
partialUpdateInstanceTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(partialUpdateInstanceMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(PartialUpdateInstanceRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put(
+ "instance.name", String.valueOf(request.getInstance().getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings deleteInstanceTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteInstanceMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteInstanceRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings createClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createClusterMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateClusterRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getClusterMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetClusterRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings listClustersTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listClustersMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListClustersRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings updateClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateClusterMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(Cluster request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings deleteClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteClusterMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteClusterRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings createAppProfileTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createAppProfileMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateAppProfileRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getAppProfileTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getAppProfileMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetAppProfileRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
listAppProfilesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listAppProfilesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListAppProfilesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings updateAppProfileTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateAppProfileMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(UpdateAppProfileRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put(
+ "app_profile.name", String.valueOf(request.getAppProfile().getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings deleteAppProfileTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteAppProfileMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteAppProfileRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getIamPolicyTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getIamPolicyMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetIamPolicyRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("resource", String.valueOf(request.getResource()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings setIamPolicyTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(setIamPolicyMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(SetIamPolicyRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("resource", String.valueOf(request.getResource()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
testIamPermissionsTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(testIamPermissionsMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(TestIamPermissionsRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("resource", String.valueOf(request.getResource()));
+ return params.build();
+ }
+ })
.build();
this.createInstanceCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createInstanceTransportSettings, settings.createInstanceSettings(), clientContext);
this.createInstanceOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
createInstanceTransportSettings,
settings.createInstanceOperationSettings(),
clientContext,
this.operationsStub);
this.getInstanceCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getInstanceTransportSettings, settings.getInstanceSettings(), clientContext);
this.listInstancesCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listInstancesTransportSettings, settings.listInstancesSettings(), clientContext);
this.partialUpdateInstanceCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
partialUpdateInstanceTransportSettings,
settings.partialUpdateInstanceSettings(),
clientContext);
this.partialUpdateInstanceOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
partialUpdateInstanceTransportSettings,
settings.partialUpdateInstanceOperationSettings(),
clientContext,
this.operationsStub);
this.deleteInstanceCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext);
this.createClusterCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createClusterTransportSettings, settings.createClusterSettings(), clientContext);
this.createClusterOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
createClusterTransportSettings,
settings.createClusterOperationSettings(),
clientContext,
this.operationsStub);
this.getClusterCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getClusterTransportSettings, settings.getClusterSettings(), clientContext);
this.listClustersCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listClustersTransportSettings, settings.listClustersSettings(), clientContext);
this.updateClusterCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
updateClusterTransportSettings, settings.updateClusterSettings(), clientContext);
this.updateClusterOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
updateClusterTransportSettings,
settings.updateClusterOperationSettings(),
clientContext,
this.operationsStub);
this.deleteClusterCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteClusterTransportSettings, settings.deleteClusterSettings(), clientContext);
this.createAppProfileCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createAppProfileTransportSettings, settings.createAppProfileSettings(), clientContext);
this.getAppProfileCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getAppProfileTransportSettings, settings.getAppProfileSettings(), clientContext);
this.listAppProfilesCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listAppProfilesTransportSettings, settings.listAppProfilesSettings(), clientContext);
this.listAppProfilesPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listAppProfilesTransportSettings, settings.listAppProfilesSettings(), clientContext);
this.updateAppProfileCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
updateAppProfileTransportSettings, settings.updateAppProfileSettings(), clientContext);
this.updateAppProfileOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
updateAppProfileTransportSettings,
settings.updateAppProfileOperationSettings(),
clientContext,
this.operationsStub);
this.deleteAppProfileCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteAppProfileTransportSettings, settings.deleteAppProfileSettings(), clientContext);
this.getIamPolicyCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext);
this.setIamPolicyCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
this.testIamPermissionsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
testIamPermissionsTransportSettings,
settings.testIamPermissionsSettings(),
clientContext);
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java
new file mode 100644
index 000000000000..26ec31a3ff3b
--- /dev/null
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.bigtable.admin.v2.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+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 v0.0.5")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcBigtableTableAdminCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java
index 7a3a23dd033c..8898182d332d 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java
@@ -22,9 +22,10 @@
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
-import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.bigtable.admin.v2.CheckConsistencyRequest;
import com.google.bigtable.admin.v2.CheckConsistencyResponse;
@@ -47,12 +48,14 @@
import com.google.bigtable.admin.v2.SnapshotTableMetadata;
import com.google.bigtable.admin.v2.SnapshotTableRequest;
import com.google.bigtable.admin.v2.Table;
+import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
@@ -208,6 +211,8 @@ public class GrpcBigtableTableAdminStub extends BigtableTableAdminStub {
listSnapshotsPagedCallable;
private final UnaryCallable deleteSnapshotCallable;
+ private final GrpcStubCallableFactory callableFactory;
+
public static final GrpcBigtableTableAdminStub create(BigtableTableAdminStubSettings settings)
throws IOException {
return new GrpcBigtableTableAdminStub(settings, ClientContext.create(settings));
@@ -219,6 +224,12 @@ public static final GrpcBigtableTableAdminStub create(ClientContext clientContex
BigtableTableAdminStubSettings.newBuilder().build(), clientContext);
}
+ public static final GrpcBigtableTableAdminStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcBigtableTableAdminStub(
+ BigtableTableAdminStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
/**
* Constructs an instance of GrpcBigtableTableAdminStub, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
@@ -226,127 +237,258 @@ public static final GrpcBigtableTableAdminStub create(ClientContext clientContex
*/
protected GrpcBigtableTableAdminStub(
BigtableTableAdminStubSettings settings, ClientContext clientContext) throws IOException {
- this.operationsStub = GrpcOperationsStub.create(clientContext);
+ this(settings, clientContext, new GrpcBigtableTableAdminCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcBigtableTableAdminStub, 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 GrpcBigtableTableAdminStub(
+ BigtableTableAdminStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings createTableTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createTableMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateTableRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
createTableFromSnapshotTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createTableFromSnapshotMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateTableFromSnapshotRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings listTablesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listTablesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListTablesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getTableTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getTableMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetTableRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings deleteTableTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteTableMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteTableRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings modifyColumnFamiliesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(modifyColumnFamiliesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ModifyColumnFamiliesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings dropRowRangeTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(dropRowRangeMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DropRowRangeRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
generateConsistencyTokenTransportSettings =
GrpcCallSettings
.newBuilder()
.setMethodDescriptor(generateConsistencyTokenMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GenerateConsistencyTokenRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings
checkConsistencyTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(checkConsistencyMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CheckConsistencyRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings snapshotTableTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(snapshotTableMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(SnapshotTableRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings getSnapshotTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getSnapshotMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetSnapshotRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings listSnapshotsTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listSnapshotsMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListSnapshotsRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
.build();
GrpcCallSettings deleteSnapshotTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteSnapshotMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteSnapshotRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
.build();
this.createTableCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createTableTransportSettings, settings.createTableSettings(), clientContext);
this.createTableFromSnapshotCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
createTableFromSnapshotTransportSettings,
settings.createTableFromSnapshotSettings(),
clientContext);
this.createTableFromSnapshotOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
createTableFromSnapshotTransportSettings,
settings.createTableFromSnapshotOperationSettings(),
clientContext,
this.operationsStub);
this.listTablesCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listTablesTransportSettings, settings.listTablesSettings(), clientContext);
this.listTablesPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listTablesTransportSettings, settings.listTablesSettings(), clientContext);
this.getTableCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getTableTransportSettings, settings.getTableSettings(), clientContext);
this.deleteTableCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteTableTransportSettings, settings.deleteTableSettings(), clientContext);
this.modifyColumnFamiliesCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
modifyColumnFamiliesTransportSettings,
settings.modifyColumnFamiliesSettings(),
clientContext);
this.dropRowRangeCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
dropRowRangeTransportSettings, settings.dropRowRangeSettings(), clientContext);
this.generateConsistencyTokenCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
generateConsistencyTokenTransportSettings,
settings.generateConsistencyTokenSettings(),
clientContext);
this.checkConsistencyCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
checkConsistencyTransportSettings, settings.checkConsistencySettings(), clientContext);
this.snapshotTableCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
snapshotTableTransportSettings, settings.snapshotTableSettings(), clientContext);
this.snapshotTableOperationCallable =
- GrpcCallableFactory.createOperationCallable(
+ callableFactory.createOperationCallable(
snapshotTableTransportSettings,
settings.snapshotTableOperationSettings(),
clientContext,
this.operationsStub);
this.getSnapshotCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
getSnapshotTransportSettings, settings.getSnapshotSettings(), clientContext);
this.listSnapshotsCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext);
this.listSnapshotsPagedCallable =
- GrpcCallableFactory.createPagedCallable(
+ callableFactory.createPagedCallable(
listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext);
this.deleteSnapshotCallable =
- GrpcCallableFactory.createUnaryCallable(
+ callableFactory.createUnaryCallable(
deleteSnapshotTransportSettings, settings.deleteSnapshotSettings(), clientContext);
backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java
index 7b7d61298e4f..316450c906e3 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java
@@ -63,7 +63,7 @@
*
* BaseBigtableDataSettings.Builder baseBigtableDataSettingsBuilder =
* BaseBigtableDataSettings.newBuilder();
- * baseBigtableDataSettingsBuilder.mutateRowSettings().getRetrySettingsBuilder()
+ * baseBigtableDataSettingsBuilder.mutateRowSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* BaseBigtableDataSettings baseBigtableDataSettings = baseBigtableDataSettingsBuilder.build();
*
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java
index 14b8a9642432..a3e8f5a93017 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java
@@ -22,7 +22,7 @@
import com.google.api.gax.rpc.ServerStream;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
-import com.google.bigtable.admin.v2.InstanceName;
+import com.google.cloud.bigtable.data.v2.models.InstanceName;
import com.google.cloud.bigtable.data.v2.models.BulkMutationBatcher;
import com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation;
import com.google.cloud.bigtable.data.v2.models.KeyOffset;
@@ -32,6 +32,7 @@
import com.google.cloud.bigtable.data.v2.models.RowAdapter;
import com.google.cloud.bigtable.data.v2.models.RowMutation;
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub;
+import com.google.protobuf.ByteString;
import java.io.IOException;
import java.util.List;
@@ -126,6 +127,44 @@ public static BigtableDataClient create(BigtableDataSettings settings) throws IO
this.stub = stub;
}
+ /**
+ * Convenience method for asynchronously reading a single row. If the row does not exist, the
+ * future's value will be null.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * InstanceName instanceName = InstanceName.of("[PROJECT]", "[INSTANCE]");
+ * try (BigtableClient bigtableClient = BigtableClient.create(instanceName)) {
+ * String tableId = "[TABLE]";
+ *
+ * ApiFuture result = bigtableClient.readRow(tableId, "key");
+ * }
+ * }
+ */
+ public ApiFuture readRowAsync(String tableId, String rowKey) {
+ return readRowAsync(tableId, ByteString.copyFromUtf8(rowKey));
+ }
+
+ /**
+ * Convenience method for asynchronously reading a single row. If the row does not exist, the
+ * future's value will be null.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * InstanceName instanceName = InstanceName.of("[PROJECT]", "[INSTANCE]");
+ * try (BigtableClient bigtableClient = BigtableClient.create(instanceName)) {
+ * String tableId = "[TABLE]";
+ *
+ * ApiFuture result = bigtableClient.readRow(tableId, ByteString.copyFromUtf8("key"));
+ * }
+ * }
+ */
+ public ApiFuture readRowAsync(String tableId, ByteString rowKey) {
+ return readRowsCallable().first().futureCall(Query.create(tableId).rowKey(rowKey));
+ }
+
/**
* Convenience method for synchronous streaming the results of a {@link Query}.
*
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
index 1067141b1486..b54fc80ab974 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
@@ -19,7 +19,7 @@
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.ServerStreamingCallSettings;
import com.google.api.gax.rpc.UnaryCallSettings;
-import com.google.bigtable.admin.v2.InstanceName;
+import com.google.cloud.bigtable.data.v2.models.InstanceName;
import com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation;
import com.google.cloud.bigtable.data.v2.models.KeyOffset;
import com.google.cloud.bigtable.data.v2.models.Query;
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java
index b8667d3f5188..eabef9c766f8 100644
--- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RequestContext.java
@@ -17,7 +17,7 @@
import com.google.api.core.InternalApi;
import com.google.auto.value.AutoValue;
-import com.google.bigtable.admin.v2.InstanceName;
+import com.google.cloud.bigtable.data.v2.models.InstanceName;
/**
* Contains information necessary to construct Bigtable protobuf requests from user facing models.
diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/InstanceName.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/InstanceName.java
new file mode 100644
index 000000000000..8465d5eb8e92
--- /dev/null
+++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/InstanceName.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.bigtable.data.v2.models;
+
+import com.google.api.pathtemplate.PathTemplate;
+import com.google.api.resourcenames.ResourceName;
+import com.google.api.resourcenames.ResourceNameType;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+// Copied from com.google.bigtable.admin.v2
+// TODO: figure out how to unify admin & data resource names
+/** Typesafe representation of a fully qualified Bigtable instance name */
+public class InstanceName implements ResourceName {
+ private static final PathTemplate PATH_TEMPLATE =
+ PathTemplate.createWithoutUrlEncoding("projects/{project}/instances/{instance}");
+
+ private volatile Map fieldValuesMap;
+
+ private final String project;
+ private final String instance;
+
+ public String getProject() {
+ return project;
+ }
+
+ public String getInstance() {
+ return instance;
+ }
+
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ private InstanceName(Builder builder) {
+ project = Preconditions.checkNotNull(builder.getProject());
+ instance = Preconditions.checkNotNull(builder.getInstance());
+ }
+
+ public static InstanceName of(String project, String instance) {
+ return newBuilder().setProject(project).setInstance(instance).build();
+ }
+
+ public static String format(String project, String instance) {
+ return newBuilder().setProject(project).setInstance(instance).build().toString();
+ }
+
+ public static InstanceName parse(String formattedString) {
+ if (formattedString.isEmpty()) {
+ return null;
+ }
+ Map matchMap =
+ PATH_TEMPLATE.validatedMatch(
+ formattedString, "InstanceName.parse: formattedString not in valid format");
+ return of(matchMap.get("project"), matchMap.get("instance"));
+ }
+
+ public static List parseList(List formattedStrings) {
+ List list = new ArrayList<>(formattedStrings.size());
+ for (String formattedString : formattedStrings) {
+ list.add(parse(formattedString));
+ }
+ return list;
+ }
+
+ public static List toStringList(List values) {
+ List list = new ArrayList(values.size());
+ for (InstanceName value : values) {
+ if (value == null) {
+ list.add("");
+ } else {
+ list.add(value.toString());
+ }
+ }
+ return list;
+ }
+
+ public static boolean isParsableFrom(String formattedString) {
+ return PATH_TEMPLATE.matches(formattedString);
+ }
+
+ public Map getFieldValuesMap() {
+ if (fieldValuesMap == null) {
+ synchronized (this) {
+ if (fieldValuesMap == null) {
+ ImmutableMap.Builder