From 592501d6150886bf9531e669733f4dd3ed7f5fa8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 9 Feb 2021 10:58:04 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#185) This PR was generated using Autosynth. :rainbow: 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: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../workflows/v1beta/WorkflowsClient.java | 294 ++++++++++++++++++ .../cloud/workflows/v1beta/package-info.java | 7 + synth.metadata | 6 +- 3 files changed, 304 insertions(+), 3 deletions(-) diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsClient.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsClient.java index fb9a1c2a..b72b74b7 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsClient.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsClient.java @@ -48,6 +48,13 @@ *

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: * + *

{@code
+ * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+ *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
+ *   Workflow response = workflowsClient.getWorkflow(name);
+ * }
+ * }
+ * *

Note: close() needs to be called on the WorkflowsClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -161,6 +168,17 @@ public final OperationsClient getOperationsClient() { /** * Lists Workflows in a given project and location. The default order is not specified. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Workflow element : workflowsClient.listWorkflows(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. Project and location from which the workflows should be listed. Format: * projects/{project}/locations/{location} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -177,6 +195,17 @@ public final ListWorkflowsPagedResponse listWorkflows(LocationName parent) { /** * Lists Workflows in a given project and location. The default order is not specified. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   for (Workflow element : workflowsClient.listWorkflows(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. Project and location from which the workflows should be listed. Format: * projects/{project}/locations/{location} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -190,6 +219,24 @@ public final ListWorkflowsPagedResponse listWorkflows(String parent) { /** * Lists Workflows in a given project and location. The default order is not specified. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   ListWorkflowsRequest request =
+   *       ListWorkflowsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .build();
+   *   for (Workflow element : workflowsClient.listWorkflows(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -202,6 +249,24 @@ public final ListWorkflowsPagedResponse listWorkflows(ListWorkflowsRequest reque * Lists Workflows in a given project and location. The default order is not specified. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   ListWorkflowsRequest request =
+   *       ListWorkflowsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .build();
+   *   ApiFuture future = workflowsClient.listWorkflowsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Workflow element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listWorkflowsPagedCallable() { @@ -213,6 +278,23 @@ public final ListWorkflowsPagedResponse listWorkflows(ListWorkflowsRequest reque * Lists Workflows in a given project and location. The default order is not specified. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   while (true) {
+   *     ListWorkflowsResponse response = workflowsClient.listWorkflowsCallable().call(request);
+   *     for (Workflow element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listWorkflowsCallable() { return stub.listWorkflowsCallable(); @@ -222,6 +304,15 @@ public final UnaryCallable listWork /** * Gets details of a single Workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
+   *   Workflow response = workflowsClient.getWorkflow(name);
+   * }
+   * }
+ * * @param name Required. Name of the workflow which information should be retrieved. Format: * projects/{project}/locations/{location}/workflows/{workflow} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -236,6 +327,15 @@ public final Workflow getWorkflow(WorkflowName name) { /** * Gets details of a single Workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   String name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
+   *   Workflow response = workflowsClient.getWorkflow(name);
+   * }
+   * }
+ * * @param name Required. Name of the workflow which information should be retrieved. Format: * projects/{project}/locations/{location}/workflows/{workflow} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -249,6 +349,18 @@ public final Workflow getWorkflow(String name) { /** * Gets details of a single Workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   GetWorkflowRequest request =
+   *       GetWorkflowRequest.newBuilder()
+   *           .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
+   *           .build();
+   *   Workflow response = workflowsClient.getWorkflow(request);
+   * }
+   * }
+ * * @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 */ @@ -261,6 +373,18 @@ public final Workflow getWorkflow(GetWorkflowRequest request) { * Gets details of a single Workflow. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   GetWorkflowRequest request =
+   *       GetWorkflowRequest.newBuilder()
+   *           .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
+   *           .build();
+   *   ApiFuture future = workflowsClient.getWorkflowCallable().futureCall(request);
+   *   // Do something.
+   *   Workflow response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getWorkflowCallable() { return stub.getWorkflowCallable(); @@ -272,6 +396,17 @@ public final UnaryCallable getWorkflowCallable() { * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Workflow workflow = Workflow.newBuilder().build();
+   *   String workflowId = "workflowId-360387270";
+   *   Workflow response = workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
+   * }
+   * }
+ * * @param parent Required. Project and location in which the workflow should be created. Format: * projects/{project}/locations/{location} * @param workflow Required. Workflow to be created. @@ -304,6 +439,17 @@ public final OperationFuture createWorkflowAsync( * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Workflow workflow = Workflow.newBuilder().build();
+   *   String workflowId = "workflowId-360387270";
+   *   Workflow response = workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
+   * }
+   * }
+ * * @param parent Required. Project and location in which the workflow should be created. Format: * projects/{project}/locations/{location} * @param workflow Required. Workflow to be created. @@ -336,6 +482,20 @@ public final OperationFuture createWorkflowAsync( * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   CreateWorkflowRequest request =
+   *       CreateWorkflowRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setWorkflowId("workflowId-360387270")
+   *           .build();
+   *   Workflow response = workflowsClient.createWorkflowAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -351,6 +511,21 @@ public final OperationFuture createWorkflowAsync( * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   CreateWorkflowRequest request =
+   *       CreateWorkflowRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setWorkflowId("workflowId-360387270")
+   *           .build();
+   *   OperationFuture future =
+   *       workflowsClient.createWorkflowOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Workflow response = future.get();
+   * }
+   * }
*/ public final OperationCallable createWorkflowOperationCallable() { @@ -364,6 +539,20 @@ public final OperationFuture createWorkflowAsync( * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   CreateWorkflowRequest request =
+   *       CreateWorkflowRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setWorkflowId("workflowId-360387270")
+   *           .build();
+   *   ApiFuture future = workflowsClient.createWorkflowCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createWorkflowCallable() { return stub.createWorkflowCallable(); @@ -374,6 +563,15 @@ public final UnaryCallable createWorkflowCalla * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
+   *   workflowsClient.deleteWorkflowAsync(name).get();
+   * }
+   * }
+ * * @param name Required. Name of the workflow to be deleted. Format: * projects/{project}/locations/{location}/workflows/{workflow} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -389,6 +587,15 @@ public final OperationFuture deleteWorkflowAsync(Workf * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   String name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
+   *   workflowsClient.deleteWorkflowAsync(name).get();
+   * }
+   * }
+ * * @param name Required. Name of the workflow to be deleted. Format: * projects/{project}/locations/{location}/workflows/{workflow} * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -403,6 +610,18 @@ public final OperationFuture deleteWorkflowAsync(Strin * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   DeleteWorkflowRequest request =
+   *       DeleteWorkflowRequest.newBuilder()
+   *           .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
+   *           .build();
+   *   workflowsClient.deleteWorkflowAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -417,6 +636,19 @@ public final OperationFuture deleteWorkflowAsync( * executions of the workflow. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   DeleteWorkflowRequest request =
+   *       DeleteWorkflowRequest.newBuilder()
+   *           .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
+   *           .build();
+   *   OperationFuture future =
+   *       workflowsClient.deleteWorkflowOperationCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final OperationCallable deleteWorkflowOperationCallable() { @@ -429,6 +661,18 @@ public final OperationFuture deleteWorkflowAsync( * executions of the workflow. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   DeleteWorkflowRequest request =
+   *       DeleteWorkflowRequest.newBuilder()
+   *           .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
+   *           .build();
+   *   ApiFuture future = workflowsClient.deleteWorkflowCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteWorkflowCallable() { return stub.deleteWorkflowCallable(); @@ -440,6 +684,16 @@ public final UnaryCallable deleteWorkflowCalla * of the workflow. A new revision of the workflow may be created as a result of a successful * update operation. In that case, such revision will be used in new workflow executions. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   Workflow workflow = Workflow.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Workflow response = workflowsClient.updateWorkflowAsync(workflow, updateMask).get();
+   * }
+   * }
+ * * @param workflow Required. Workflow to be updated. * @param updateMask List of fields to be updated. If not present, the entire workflow will be * updated. @@ -458,6 +712,19 @@ public final OperationFuture updateWorkflowAsync( * of the workflow. A new revision of the workflow may be created as a result of a successful * update operation. In that case, such revision will be used in new workflow executions. * + *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   UpdateWorkflowRequest request =
+   *       UpdateWorkflowRequest.newBuilder()
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Workflow response = workflowsClient.updateWorkflowAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -473,6 +740,20 @@ public final OperationFuture updateWorkflowAsync( * update operation. In that case, such revision will be used in new workflow executions. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   UpdateWorkflowRequest request =
+   *       UpdateWorkflowRequest.newBuilder()
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       workflowsClient.updateWorkflowOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Workflow response = future.get();
+   * }
+   * }
*/ public final OperationCallable updateWorkflowOperationCallable() { @@ -486,6 +767,19 @@ public final OperationFuture updateWorkflowAsync( * update operation. In that case, such revision will be used in new workflow executions. * *

Sample code: + * + *

{@code
+   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+   *   UpdateWorkflowRequest request =
+   *       UpdateWorkflowRequest.newBuilder()
+   *           .setWorkflow(Workflow.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = workflowsClient.updateWorkflowCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateWorkflowCallable() { return stub.updateWorkflowCallable(); diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/package-info.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/package-info.java index cea98754..f4483118 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/package-info.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/package-info.java @@ -23,6 +23,13 @@ * makes sure the program executes reliably, despite hardware and networking interruptions. * *

Sample for WorkflowsClient: + * + *

{@code
+ * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
+ *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
+ *   Workflow response = workflowsClient.getWorkflow(name);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.workflows.v1beta; diff --git a/synth.metadata b/synth.metadata index c0a24d34..ed7437a5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-workflows.git", - "sha": "9ba76337363fac2de84c22ea84386726a0a0c198" + "sha": "529aa0e71150e7e6c1f99627e0bfc6c81b8a22dd" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {