Skip to content

Commit

Permalink
feat: re-generated to pick up changes from googleapis. (#435)
Browse files Browse the repository at this point in the history
* changes without context

        autosynth cannot find the source of changes triggered by earlier changes in this
        repository, or by version upgrades to tools such as linters.

* feat: migrate bq/storage/v1beta1 to gapic v2

- adds new resource name classes

PiperOrigin-RevId: 322235422

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Jul 20 15:14:29 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: d7a347b819096886f4644b0ed5a978a777f4bbb4
Source-Link: googleapis/googleapis@d7a347b

* fix: add missing resource name deps to v1beta1 (#436)

Co-authored-by: Noah Dietz <noahdietz@users.noreply.github.com>
  • Loading branch information
yoshi-automation and noahdietz committed Jul 21, 2020
1 parent e83b6b3 commit bdf35e0
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -38,7 +38,7 @@ If you are using Maven without BOM, add this to your dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquerystorage</artifactId>
<version>1.1.1</version>
<version>1.2.0</version>
</dependency>

```
Expand Down
Expand Up @@ -50,7 +50,7 @@
* <code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* String parent = "";
* ProjectName parent = ProjectName.of("[PROJECT]");
* int requestedStreams = 0;
* ReadSession response = baseBigQueryStorageClient.createReadSession(tableReference, parent, requestedStreams);
* }
Expand Down Expand Up @@ -180,7 +180,7 @@ public BigQueryStorageStub getStub() {
* <pre><code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* String parent = "";
* ProjectName parent = ProjectName.of("[PROJECT]");
* int requestedStreams = 0;
* ReadSession response = baseBigQueryStorageClient.createReadSession(tableReference, parent, requestedStreams);
* }
Expand All @@ -196,6 +196,51 @@ public BigQueryStorageStub getStub() {
* <p>Streams must be read starting from offset 0.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ReadSession createReadSession(
TableReference tableReference, ProjectName parent, int requestedStreams) {
CreateReadSessionRequest request =
CreateReadSessionRequest.newBuilder()
.setTableReference(tableReference)
.setParent(parent == null ? null : parent.toString())
.setRequestedStreams(requestedStreams)
.build();
return createReadSession(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates a new read session. A read session divides the contents of a BigQuery table into one or
* more streams, which can then be used to read data from the table. The read session also
* specifies properties of the data to be read, such as a list of columns or a push-down filter
* describing the rows to be returned.
*
* <p>A particular row can be read by at most one stream. When the caller has reached the end of
* each stream in the session, then all the data in the table has been read.
*
* <p>Read sessions automatically expire 24 hours after they are created and do not require manual
* clean-up by the caller.
*
* <p>Sample code:
*
* <pre><code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* ProjectName parent = ProjectName.of("[PROJECT]");
* int requestedStreams = 0;
* ReadSession response = baseBigQueryStorageClient.createReadSession(tableReference, parent.toString(), requestedStreams);
* }
* </code></pre>
*
* @param tableReference Required. Reference to the table to read.
* @param parent Required. String of the form `projects/{project_id}` indicating the project this
* ReadSession is associated with. This is the project that will be billed for usage.
* @param requestedStreams Initial number of streams. If unset or 0, we will provide a value of
* streams so as to produce reasonable throughput. Must be non-negative. The number of streams
* may be lower than the requested number, depending on the amount parallelism that is
* reasonable for the table and the maximum amount of parallelism allowed by the system.
* <p>Streams must be read starting from offset 0.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ReadSession createReadSession(
TableReference tableReference, String parent, int requestedStreams) {
CreateReadSessionRequest request =
Expand Down Expand Up @@ -225,10 +270,10 @@ public final ReadSession createReadSession(
* <pre><code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* String parent = "";
* ProjectName parent = ProjectName.of("[PROJECT]");
* CreateReadSessionRequest request = CreateReadSessionRequest.newBuilder()
* .setTableReference(tableReference)
* .setParent(parent)
* .setParent(parent.toString())
* .build();
* ReadSession response = baseBigQueryStorageClient.createReadSession(request);
* }
Expand Down Expand Up @@ -259,10 +304,10 @@ public final ReadSession createReadSession(CreateReadSessionRequest request) {
* <pre><code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* String parent = "";
* ProjectName parent = ProjectName.of("[PROJECT]");
* CreateReadSessionRequest request = CreateReadSessionRequest.newBuilder()
* .setTableReference(tableReference)
* .setParent(parent)
* .setParent(parent.toString())
* .build();
* ApiFuture&lt;ReadSession&gt; future = baseBigQueryStorageClient.createReadSessionCallable().futureCall(request);
* // Do something
Expand Down
Expand Up @@ -31,7 +31,7 @@
* <code>
* try (BaseBigQueryStorageClient baseBigQueryStorageClient = BaseBigQueryStorageClient.create()) {
* TableReference tableReference = TableReference.newBuilder().build();
* String parent = "";
* ProjectName parent = ProjectName.of("[PROJECT]");
* int requestedStreams = 0;
* ReadSession response = baseBigQueryStorageClient.createReadSession(tableReference, parent, requestedStreams);
* }
Expand Down
Expand Up @@ -229,13 +229,18 @@ public static class Builder extends StubSettings.Builder<BigQueryStorageStubSett
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
"retry_policy_1_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"unary_streaming",
"retry_policy_3_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put(
"retry_policy_2_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}
Expand All @@ -250,34 +255,36 @@ public static class Builder extends StubSettings.Builder<BigQueryStorageStubSett
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(20000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(20000L))
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.build();
definitions.put("default", settings);
definitions.put("retry_policy_1_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(120000L))
.setInitialRpcTimeout(Duration.ofMillis(86400000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(120000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(86400000L))
.setTotalTimeout(Duration.ofMillis(86400000L))
.build();
definitions.put("create_read_session", settings);
definitions.put("retry_policy_2_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(86400000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(86400000L))
.setTotalTimeout(Duration.ofMillis(86400000L))
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.build();
definitions.put("read_rows", settings);
definitions.put("retry_policy_3_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -321,28 +328,28 @@ private static Builder initDefaults(Builder builder) {

builder
.createReadSessionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("create_read_session"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.readRowsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("unary_streaming"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("read_rows"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params"));

builder
.batchCreateReadSessionStreamsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.finalizeStreamSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.splitReadStreamSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

return builder;
}
Expand Down
Expand Up @@ -94,12 +94,12 @@ public void tearDown() throws Exception {
@Test
@SuppressWarnings("all")
public void createReadSessionTest() {
String name = "name3373707";
ReadSession expectedResponse = ReadSession.newBuilder().setName(name).build();
ReadSessionName name = ReadSessionName.of("[PROJECT]", "[LOCATION]", "[SESSION]");
ReadSession expectedResponse = ReadSession.newBuilder().setName(name.toString()).build();
mockBigQueryStorage.addResponse(expectedResponse);

TableReference tableReference = TableReference.newBuilder().build();
String parent = "parent-995424086";
ProjectName parent = ProjectName.of("[PROJECT]");
int requestedStreams = 1017221410;

ReadSession actualResponse = client.createReadSession(tableReference, parent, requestedStreams);
Expand All @@ -110,7 +110,7 @@ public void createReadSessionTest() {
CreateReadSessionRequest actualRequest = (CreateReadSessionRequest) actualRequests.get(0);

Assert.assertEquals(tableReference, actualRequest.getTableReference());
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(requestedStreams, actualRequest.getRequestedStreams());
Assert.assertTrue(
channelProvider.isHeaderSent(
Expand All @@ -126,7 +126,7 @@ public void createReadSessionExceptionTest() throws Exception {

try {
TableReference tableReference = TableReference.newBuilder().build();
String parent = "parent-995424086";
ProjectName parent = ProjectName.of("[PROJECT]");
int requestedStreams = 1017221410;

client.createReadSession(tableReference, parent, requestedStreams);
Expand Down
10 changes: 9 additions & 1 deletion proto-google-cloud-bigquerystorage-v1beta1/pom.xml
Expand Up @@ -21,6 +21,14 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -31,4 +39,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

0 comments on commit bdf35e0

Please sign in to comment.