Skip to content
This repository was archived by the owner on Jul 17, 2023. It is now read-only.

Commit 26bc136

Browse files
docs: generate sample code in the Java microgenerator (#56)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/b5715173-fa09-4f29-8c69-530ae787b970/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: googleapis/googleapis@8d8c008
1 parent d177e1d commit 26bc136

File tree

3 files changed

+231
-3
lines changed

3 files changed

+231
-3
lines changed

google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClient.java

+220
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
* <p>This class provides the ability to make remote calls to the backing service through method
4343
* calls that map to API methods. Sample code to get started:
4444
*
45+
* <pre>{@code
46+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
47+
* WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
48+
* Execution execution = Execution.newBuilder().build();
49+
* Execution response = executionsClient.createExecution(parent, execution);
50+
* }
51+
* }</pre>
52+
*
4553
* <p>Note: close() needs to be called on the ExecutionsClient object to clean up resources such as
4654
* threads. In the example above, try-with-resources is used, which automatically calls close().
4755
*
@@ -146,6 +154,17 @@ public ExecutionsStub getStub() {
146154
* returns executions of all workflow revisions. Returned executions are ordered by their start
147155
* time (newest first).
148156
*
157+
* <p>Sample code:
158+
*
159+
* <pre>{@code
160+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
161+
* WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
162+
* for (Execution element : executionsClient.listExecutions(parent).iterateAll()) {
163+
* // doThingsWith(element);
164+
* }
165+
* }
166+
* }</pre>
167+
*
149168
* @param parent Required. Name of the workflow for which the executions should be listed. Format:
150169
* projects/{project}/locations/{location}/workflows/{workflow}
151170
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -164,6 +183,17 @@ public final ListExecutionsPagedResponse listExecutions(WorkflowName parent) {
164183
* returns executions of all workflow revisions. Returned executions are ordered by their start
165184
* time (newest first).
166185
*
186+
* <p>Sample code:
187+
*
188+
* <pre>{@code
189+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
190+
* String parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
191+
* for (Execution element : executionsClient.listExecutions(parent).iterateAll()) {
192+
* // doThingsWith(element);
193+
* }
194+
* }
195+
* }</pre>
196+
*
167197
* @param parent Required. Name of the workflow for which the executions should be listed. Format:
168198
* projects/{project}/locations/{location}/workflows/{workflow}
169199
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -179,6 +209,22 @@ public final ListExecutionsPagedResponse listExecutions(String parent) {
179209
* returns executions of all workflow revisions. Returned executions are ordered by their start
180210
* time (newest first).
181211
*
212+
* <p>Sample code:
213+
*
214+
* <pre>{@code
215+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
216+
* ListExecutionsRequest request =
217+
* ListExecutionsRequest.newBuilder()
218+
* .setParent(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
219+
* .setPageSize(883849137)
220+
* .setPageToken("pageToken873572522")
221+
* .build();
222+
* for (Execution element : executionsClient.listExecutions(request).iterateAll()) {
223+
* // doThingsWith(element);
224+
* }
225+
* }
226+
* }</pre>
227+
*
182228
* @param request The request object containing all of the parameters for the API call.
183229
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
184230
*/
@@ -193,6 +239,23 @@ public final ListExecutionsPagedResponse listExecutions(ListExecutionsRequest re
193239
* time (newest first).
194240
*
195241
* <p>Sample code:
242+
*
243+
* <pre>{@code
244+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
245+
* ListExecutionsRequest request =
246+
* ListExecutionsRequest.newBuilder()
247+
* .setParent(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
248+
* .setPageSize(883849137)
249+
* .setPageToken("pageToken873572522")
250+
* .build();
251+
* ApiFuture<Execution> future =
252+
* executionsClient.listExecutionsPagedCallable().futureCall(request);
253+
* // Do something.
254+
* for (Execution element : future.get().iterateAll()) {
255+
* // doThingsWith(element);
256+
* }
257+
* }
258+
* }</pre>
196259
*/
197260
public final UnaryCallable<ListExecutionsRequest, ListExecutionsPagedResponse>
198261
listExecutionsPagedCallable() {
@@ -206,6 +269,23 @@ public final ListExecutionsPagedResponse listExecutions(ListExecutionsRequest re
206269
* time (newest first).
207270
*
208271
* <p>Sample code:
272+
*
273+
* <pre>{@code
274+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
275+
* while (true) {
276+
* ListExecutionsResponse response = executionsClient.listExecutionsCallable().call(request);
277+
* for (Execution element : response.getResponsesList()) {
278+
* // doThingsWith(element);
279+
* }
280+
* String nextPageToken = response.getNextPageToken();
281+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
282+
* request = request.toBuilder().setPageToken(nextPageToken).build();
283+
* } else {
284+
* break;
285+
* }
286+
* }
287+
* }
288+
* }</pre>
209289
*/
210290
public final UnaryCallable<ListExecutionsRequest, ListExecutionsResponse>
211291
listExecutionsCallable() {
@@ -216,6 +296,16 @@ public final ListExecutionsPagedResponse listExecutions(ListExecutionsRequest re
216296
/**
217297
* Creates a new execution using the latest revision of the given workflow.
218298
*
299+
* <p>Sample code:
300+
*
301+
* <pre>{@code
302+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
303+
* WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
304+
* Execution execution = Execution.newBuilder().build();
305+
* Execution response = executionsClient.createExecution(parent, execution);
306+
* }
307+
* }</pre>
308+
*
219309
* @param parent Required. Name of the workflow for which an execution should be created. Format:
220310
* projects/{project}/locations/{location}/workflows/{workflow} The latest revision of the
221311
* workflow will be used.
@@ -235,6 +325,16 @@ public final Execution createExecution(WorkflowName parent, Execution execution)
235325
/**
236326
* Creates a new execution using the latest revision of the given workflow.
237327
*
328+
* <p>Sample code:
329+
*
330+
* <pre>{@code
331+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
332+
* String parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
333+
* Execution execution = Execution.newBuilder().build();
334+
* Execution response = executionsClient.createExecution(parent, execution);
335+
* }
336+
* }</pre>
337+
*
238338
* @param parent Required. Name of the workflow for which an execution should be created. Format:
239339
* projects/{project}/locations/{location}/workflows/{workflow} The latest revision of the
240340
* workflow will be used.
@@ -251,6 +351,19 @@ public final Execution createExecution(String parent, Execution execution) {
251351
/**
252352
* Creates a new execution using the latest revision of the given workflow.
253353
*
354+
* <p>Sample code:
355+
*
356+
* <pre>{@code
357+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
358+
* CreateExecutionRequest request =
359+
* CreateExecutionRequest.newBuilder()
360+
* .setParent(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
361+
* .setExecution(Execution.newBuilder().build())
362+
* .build();
363+
* Execution response = executionsClient.createExecution(request);
364+
* }
365+
* }</pre>
366+
*
254367
* @param request The request object containing all of the parameters for the API call.
255368
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
256369
*/
@@ -263,6 +376,19 @@ public final Execution createExecution(CreateExecutionRequest request) {
263376
* Creates a new execution using the latest revision of the given workflow.
264377
*
265378
* <p>Sample code:
379+
*
380+
* <pre>{@code
381+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
382+
* CreateExecutionRequest request =
383+
* CreateExecutionRequest.newBuilder()
384+
* .setParent(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
385+
* .setExecution(Execution.newBuilder().build())
386+
* .build();
387+
* ApiFuture<Execution> future = executionsClient.createExecutionCallable().futureCall(request);
388+
* // Do something.
389+
* Execution response = future.get();
390+
* }
391+
* }</pre>
266392
*/
267393
public final UnaryCallable<CreateExecutionRequest, Execution> createExecutionCallable() {
268394
return stub.createExecutionCallable();
@@ -272,6 +398,15 @@ public final UnaryCallable<CreateExecutionRequest, Execution> createExecutionCal
272398
/**
273399
* Returns an execution of the given name.
274400
*
401+
* <p>Sample code:
402+
*
403+
* <pre>{@code
404+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
405+
* ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]");
406+
* Execution response = executionsClient.getExecution(name);
407+
* }
408+
* }</pre>
409+
*
275410
* @param name Required. Name of the execution to be retrieved. Format:
276411
* projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}
277412
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -286,6 +421,16 @@ public final Execution getExecution(ExecutionName name) {
286421
/**
287422
* Returns an execution of the given name.
288423
*
424+
* <p>Sample code:
425+
*
426+
* <pre>{@code
427+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
428+
* String name =
429+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString();
430+
* Execution response = executionsClient.getExecution(name);
431+
* }
432+
* }</pre>
433+
*
289434
* @param name Required. Name of the execution to be retrieved. Format:
290435
* projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}
291436
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -299,6 +444,20 @@ public final Execution getExecution(String name) {
299444
/**
300445
* Returns an execution of the given name.
301446
*
447+
* <p>Sample code:
448+
*
449+
* <pre>{@code
450+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
451+
* GetExecutionRequest request =
452+
* GetExecutionRequest.newBuilder()
453+
* .setName(
454+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]")
455+
* .toString())
456+
* .build();
457+
* Execution response = executionsClient.getExecution(request);
458+
* }
459+
* }</pre>
460+
*
302461
* @param request The request object containing all of the parameters for the API call.
303462
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
304463
*/
@@ -311,6 +470,20 @@ public final Execution getExecution(GetExecutionRequest request) {
311470
* Returns an execution of the given name.
312471
*
313472
* <p>Sample code:
473+
*
474+
* <pre>{@code
475+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
476+
* GetExecutionRequest request =
477+
* GetExecutionRequest.newBuilder()
478+
* .setName(
479+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]")
480+
* .toString())
481+
* .build();
482+
* ApiFuture<Execution> future = executionsClient.getExecutionCallable().futureCall(request);
483+
* // Do something.
484+
* Execution response = future.get();
485+
* }
486+
* }</pre>
314487
*/
315488
public final UnaryCallable<GetExecutionRequest, Execution> getExecutionCallable() {
316489
return stub.getExecutionCallable();
@@ -320,6 +493,15 @@ public final UnaryCallable<GetExecutionRequest, Execution> getExecutionCallable(
320493
/**
321494
* Cancels an execution of the given name.
322495
*
496+
* <p>Sample code:
497+
*
498+
* <pre>{@code
499+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
500+
* ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]");
501+
* Execution response = executionsClient.cancelExecution(name);
502+
* }
503+
* }</pre>
504+
*
323505
* @param name Required. Name of the execution to be cancelled. Format:
324506
* projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}
325507
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -334,6 +516,16 @@ public final Execution cancelExecution(ExecutionName name) {
334516
/**
335517
* Cancels an execution of the given name.
336518
*
519+
* <p>Sample code:
520+
*
521+
* <pre>{@code
522+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
523+
* String name =
524+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString();
525+
* Execution response = executionsClient.cancelExecution(name);
526+
* }
527+
* }</pre>
528+
*
337529
* @param name Required. Name of the execution to be cancelled. Format:
338530
* projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution}
339531
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -347,6 +539,20 @@ public final Execution cancelExecution(String name) {
347539
/**
348540
* Cancels an execution of the given name.
349541
*
542+
* <p>Sample code:
543+
*
544+
* <pre>{@code
545+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
546+
* CancelExecutionRequest request =
547+
* CancelExecutionRequest.newBuilder()
548+
* .setName(
549+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]")
550+
* .toString())
551+
* .build();
552+
* Execution response = executionsClient.cancelExecution(request);
553+
* }
554+
* }</pre>
555+
*
350556
* @param request The request object containing all of the parameters for the API call.
351557
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
352558
*/
@@ -359,6 +565,20 @@ public final Execution cancelExecution(CancelExecutionRequest request) {
359565
* Cancels an execution of the given name.
360566
*
361567
* <p>Sample code:
568+
*
569+
* <pre>{@code
570+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
571+
* CancelExecutionRequest request =
572+
* CancelExecutionRequest.newBuilder()
573+
* .setName(
574+
* ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]")
575+
* .toString())
576+
* .build();
577+
* ApiFuture<Execution> future = executionsClient.cancelExecutionCallable().futureCall(request);
578+
* // Do something.
579+
* Execution response = future.get();
580+
* }
581+
* }</pre>
362582
*/
363583
public final UnaryCallable<CancelExecutionRequest, Execution> cancelExecutionCallable() {
364584
return stub.cancelExecutionCallable();

google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/package-info.java

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
* [Workflows][google.cloud.workflows.v1beta.Workflow] called executions.
2424
*
2525
* <p>Sample for ExecutionsClient:
26+
*
27+
* <pre>{@code
28+
* try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
29+
* WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
30+
* Execution execution = Execution.newBuilder().build();
31+
* Execution response = executionsClient.createExecution(parent, execution);
32+
* }
33+
* }</pre>
2634
*/
2735
@Generated("by gapic-generator-java")
2836
package com.google.cloud.workflows.executions.v1beta;

synth.metadata

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-workflow-executions.git",
7-
"sha": "7d56d439c72df1b3e9ee80d95b619c9607860ca4"
7+
"sha": "d177e1d797b6793c913f1c7d5e5fa8bf91319041"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3",
15-
"internalRef": "350949863"
14+
"sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb",
15+
"internalRef": "356341083"
1616
}
1717
},
1818
{

0 commit comments

Comments
 (0)