Skip to content
Permalink
Browse files
feat: generate sample code in the Java microgenerator (#821)
Committer: @miraleung
PiperOrigin-RevId: 356341083

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Feb 8 13:33:28 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 8d8c008e56f1af31d57f75561e0f1848ffb29eeb
Source-Link: googleapis/googleapis@8d8c008
  • Loading branch information
yoshi-automation committed Feb 9, 2021
1 parent ba4b1a2 commit 3ab9a309441a681e8adec88f8b8af1298a89cd74
@@ -35,6 +35,16 @@
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ReadSession readSession = ReadSession.newBuilder().build();
* int maxStreamCount = 940837515;
* ReadSession response =
* baseBigQueryReadClient.createReadSession(parent, readSession, maxStreamCount);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the BaseBigQueryReadClient object to clean up resources
* such as threads. In the example above, try-with-resources is used, which automatically calls
* close().
@@ -156,6 +166,18 @@ public BigQueryReadStub getStub() {
* <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 (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ReadSession readSession = ReadSession.newBuilder().build();
* int maxStreamCount = 940837515;
* ReadSession response =
* baseBigQueryReadClient.createReadSession(parent, readSession, maxStreamCount);
* }
* }</pre>
*
* @param parent Required. The request project that owns the session, in the form of
* `projects/{project_id}`.
* @param readSession Required. Session to be created.
@@ -197,6 +219,18 @@ public final ReadSession createReadSession(
* <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 (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* String parent = ProjectName.of("[PROJECT]").toString();
* ReadSession readSession = ReadSession.newBuilder().build();
* int maxStreamCount = 940837515;
* ReadSession response =
* baseBigQueryReadClient.createReadSession(parent, readSession, maxStreamCount);
* }
* }</pre>
*
* @param parent Required. The request project that owns the session, in the form of
* `projects/{project_id}`.
* @param readSession Required. Session to be created.
@@ -238,6 +272,20 @@ public final ReadSession createReadSession(
* <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 (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* CreateReadSessionRequest request =
* CreateReadSessionRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setReadSession(ReadSession.newBuilder().build())
* .setMaxStreamCount(940837515)
* .build();
* ReadSession response = baseBigQueryReadClient.createReadSession(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -265,6 +313,21 @@ public final ReadSession createReadSession(CreateReadSessionRequest request) {
* clean-up by the caller.
*
* <p>Sample code:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* CreateReadSessionRequest request =
* CreateReadSessionRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setReadSession(ReadSession.newBuilder().build())
* .setMaxStreamCount(940837515)
* .build();
* ApiFuture<ReadSession> future =
* baseBigQueryReadClient.createReadSessionCallable().futureCall(request);
* // Do something.
* ReadSession response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CreateReadSessionRequest, ReadSession> createReadSessionCallable() {
return stub.createReadSessionCallable();
@@ -280,6 +343,22 @@ public final UnaryCallable<CreateReadSessionRequest, ReadSession> createReadSess
* stream.
*
* <p>Sample code:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* ReadRowsRequest request =
* ReadRowsRequest.newBuilder()
* .setReadStream(
* ReadStreamName.of("[PROJECT]", "[LOCATION]", "[SESSION]", "[STREAM]").toString())
* .setOffset(-1019779949)
* .build();
* ServerStream<ReadRowsResponse> stream =
* baseBigQueryReadClient.readRowsCallable().call(request);
* for (ReadRowsResponse response : stream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> readRowsCallable() {
return stub.readRowsCallable();
@@ -298,6 +377,20 @@ public final ServerStreamingCallable<ReadRowsRequest, ReadRowsResponse> readRows
* original[0-j] = primary[0-j] and original[j-n] = residual[0-m] once the streams have been read
* to completion.
*
* <p>Sample code:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* SplitReadStreamRequest request =
* SplitReadStreamRequest.newBuilder()
* .setName(
* ReadStreamName.of("[PROJECT]", "[LOCATION]", "[SESSION]", "[STREAM]").toString())
* .setFraction(-1653751294)
* .build();
* SplitReadStreamResponse response = baseBigQueryReadClient.splitReadStream(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -319,6 +412,21 @@ public final SplitReadStreamResponse splitReadStream(SplitReadStreamRequest requ
* to completion.
*
* <p>Sample code:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* SplitReadStreamRequest request =
* SplitReadStreamRequest.newBuilder()
* .setName(
* ReadStreamName.of("[PROJECT]", "[LOCATION]", "[SESSION]", "[STREAM]").toString())
* .setFraction(-1653751294)
* .build();
* ApiFuture<SplitReadStreamResponse> future =
* baseBigQueryReadClient.splitReadStreamCallable().futureCall(request);
* // Do something.
* SplitReadStreamResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SplitReadStreamRequest, SplitReadStreamResponse>
splitReadStreamCallable() {
@@ -24,6 +24,16 @@
* <p>The Read API can be used to read data from BigQuery.
*
* <p>Sample for BaseBigQueryReadClient:
*
* <pre>{@code
* try (BaseBigQueryReadClient baseBigQueryReadClient = BaseBigQueryReadClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ReadSession readSession = ReadSession.newBuilder().build();
* int maxStreamCount = 940837515;
* ReadSession response =
* baseBigQueryReadClient.createReadSession(parent, readSession, maxStreamCount);
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.bigquery.storage.v1;
@@ -66,18 +66,18 @@
* <p>For example, to set the total timeout of createReadSession to 30 seconds:
*
* <pre>{@code
* BigQueryReadStubSettings.Builder bigQueryReadSettingsBuilder =
* BigQueryReadStubSettings.Builder baseBigQueryReadSettingsBuilder =
* BigQueryReadStubSettings.newBuilder();
* bigQueryReadSettingsBuilder
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .setRetrySettings(
* bigQueryReadSettingsBuilder
* baseBigQueryReadSettingsBuilder
* .createReadSessionSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* BigQueryReadStubSettings bigQueryReadSettings = bigQueryReadSettingsBuilder.build();
* BigQueryReadStubSettings baseBigQueryReadSettings = baseBigQueryReadSettingsBuilder.build();
* }</pre>
*/
@Generated("by gapic-generator-java")

0 comments on commit 3ab9a30

Please sign in to comment.