Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate sample code in the Java microgenerator #821

Merged
merged 1 commit into from Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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().
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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
*/
Expand All @@ -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() {
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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")
Expand Down