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 1198df31..1dfd1bcb 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 @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta; import com.google.api.core.ApiFunction; @@ -39,7 +40,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Workflows is used to deploy and execute workflow programs. Workflows makes * sure the program executes reliably, despite hardware and networking interruptions. @@ -47,16 +48,7 @@ *

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

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

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(). * *

The surface of this class includes several types of Java methods for each of the API's @@ -84,30 +76,26 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * WorkflowsSettings workflowsSettings =
  *     WorkflowsSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * WorkflowsClient workflowsClient =
- *     WorkflowsClient.create(workflowsSettings);
- * 
- * 
+ * WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings); + * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * WorkflowsSettings workflowsSettings =
  *     WorkflowsSettings.newBuilder().setEndpoint(myEndpoint).build();
- * WorkflowsClient workflowsClient =
- *     WorkflowsClient.create(workflowsSettings);
- * 
- * 
+ * WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings); + * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class WorkflowsClient implements BackgroundResource { private final WorkflowsSettings settings; private final WorkflowsStub stub; @@ -128,7 +116,7 @@ public static final WorkflowsClient create(WorkflowsSettings settings) throws IO /** * Constructs an instance of WorkflowsClient, using the given stub for making calls. This is for - * advanced usage - prefer to use WorkflowsSettings}. + * advanced usage - prefer using create(WorkflowsSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final WorkflowsClient create(WorkflowsStub stub) { @@ -165,27 +153,14 @@ public WorkflowsStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient() { return operationsClient; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Workflows in a given project and location. The default order is not specified. * - *

Sample 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 @@ -198,21 +173,10 @@ public final ListWorkflowsPagedResponse listWorkflows(LocationName parent) { return listWorkflows(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Workflows in a given project and location. The default order is not specified. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (Workflow element : workflowsClient.listWorkflows(parent.toString()).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 @@ -222,24 +186,10 @@ public final ListWorkflowsPagedResponse listWorkflows(String parent) { return listWorkflows(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Workflows in a given project and location. The default order is not specified. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListWorkflowsRequest request = ListWorkflowsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 */ @@ -247,75 +197,31 @@ public final ListWorkflowsPagedResponse listWorkflows(ListWorkflowsRequest reque return listWorkflowsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Workflows in a given project and location. The default order is not specified. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListWorkflowsRequest request = ListWorkflowsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListWorkflowsPagedResponse> future = workflowsClient.listWorkflowsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Workflow element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listWorkflowsPagedCallable() { return stub.listWorkflowsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Workflows in a given project and location. The default order is not specified. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListWorkflowsRequest request = ListWorkflowsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListWorkflowsResponse response = workflowsClient.listWorkflowsCallable().call(request);
-   *     for (Workflow element : response.getWorkflowsList()) {
-   *       // 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(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets details of a single Workflow. * - *

Sample 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 @@ -326,19 +232,10 @@ public final Workflow getWorkflow(WorkflowName name) { return getWorkflow(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets details of a single Workflow. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   Workflow response = workflowsClient.getWorkflow(name.toString());
-   * }
-   * 
- * * @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 @@ -348,22 +245,10 @@ public final Workflow getWorkflow(String name) { return getWorkflow(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets details of a single Workflow. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   GetWorkflowRequest request = GetWorkflowRequest.newBuilder()
-   *     .setName(name.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 */ @@ -371,57 +256,37 @@ public final Workflow getWorkflow(GetWorkflowRequest request) { return getWorkflowCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets details of a single Workflow. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   GetWorkflowRequest request = GetWorkflowRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Workflow> future = workflowsClient.getWorkflowCallable().futureCall(request);
-   *   // Do something
-   *   Workflow response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getWorkflowCallable() { return stub.getWorkflowCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new workflow. If a workflow with the specified name already exists in the specified * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   String workflowId = "";
-   *   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. - * @param workflowId Required. The ID of the workflow to be created. It has to fulfill the + * @param workflow_id Required. The ID of the workflow to be created. It has to fulfill the * following requirements: - *

* Must contain only letters, numbers, underscores and hyphens. * Must start with - * a letter. * Must be between 1-64 characters. * Must end with a number or a letter. - * * Must be unique within the customer project and location. + *

    + *
  • Must contain only letters, numbers, underscores and hyphens. + *
  • Must start with a letter. + *
  • Must be between 1-64 characters. + *
  • Must end with a number or a letter. + *
  • Must be unique within the customer project and location. + *
+ * * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createWorkflowAsync( LocationName parent, Workflow workflow, String workflowId) { CreateWorkflowRequest request = @@ -433,35 +298,27 @@ public final OperationFuture createWorkflowAsync( return createWorkflowAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new workflow. If a workflow with the specified name already exists in the specified * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   String workflowId = "";
-   *   Workflow response = workflowsClient.createWorkflowAsync(parent.toString(), 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. - * @param workflowId Required. The ID of the workflow to be created. It has to fulfill the + * @param workflow_id Required. The ID of the workflow to be created. It has to fulfill the * following requirements: - *

* Must contain only letters, numbers, underscores and hyphens. * Must start with - * a letter. * Must be between 1-64 characters. * Must end with a number or a letter. - * * Must be unique within the customer project and location. + *

    + *
  • Must contain only letters, numbers, underscores and hyphens. + *
  • Must start with a letter. + *
  • Must be between 1-64 characters. + *
  • Must end with a number or a letter. + *
  • Must be unique within the customer project and location. + *
+ * * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createWorkflowAsync( String parent, Workflow workflow, String workflowId) { CreateWorkflowRequest request = @@ -473,245 +330,121 @@ public final OperationFuture createWorkflowAsync( return createWorkflowAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new workflow. If a workflow with the specified name already exists in the specified * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   String workflowId = "";
-   *   CreateWorkflowRequest request = CreateWorkflowRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setWorkflow(workflow)
-   *     .setWorkflowId(workflowId)
-   *     .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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createWorkflowAsync( CreateWorkflowRequest request) { return createWorkflowOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new workflow. If a workflow with the specified name already exists in the specified * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   String workflowId = "";
-   *   CreateWorkflowRequest request = CreateWorkflowRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setWorkflow(workflow)
-   *     .setWorkflowId(workflowId)
-   *     .build();
-   *   OperationFuture<Workflow, OperationMetadata> future = workflowsClient.createWorkflowOperationCallable().futureCall(request);
-   *   // Do something
-   *   Workflow response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable createWorkflowOperationCallable() { return stub.createWorkflowOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new workflow. If a workflow with the specified name already exists in the specified * project and location, the long running operation will return * [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   String workflowId = "";
-   *   CreateWorkflowRequest request = CreateWorkflowRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setWorkflow(workflow)
-   *     .setWorkflowId(workflowId)
-   *     .build();
-   *   ApiFuture<Operation> future = workflowsClient.createWorkflowCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createWorkflowCallable() { return stub.createWorkflowCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * - *

Sample 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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteWorkflowAsync(WorkflowName name) { DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return deleteWorkflowAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   workflowsClient.deleteWorkflowAsync(name.toString()).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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteWorkflowAsync(String name) { DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder().setName(name).build(); return deleteWorkflowAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * - *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder()
-   *     .setName(name.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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteWorkflowAsync( DeleteWorkflowRequest request) { return deleteWorkflowOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   OperationFuture<Empty, OperationMetadata> future = workflowsClient.deleteWorkflowOperationCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable deleteWorkflowOperationCallable() { return stub.deleteWorkflowOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a workflow with the specified name. This method also cancels and deletes all running * executions of the workflow. * *

Sample code: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
-   *   DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = workflowsClient.deleteWorkflowCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteWorkflowCallable() { return stub.deleteWorkflowCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates an existing workflow. Running this method has no impact on already running executions * 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: - * - *


-   * 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 + * @param update_mask List of fields to be updated. If not present, the entire workflow will be * updated. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture updateWorkflowAsync( Workflow workflow, FieldMask updateMask) { UpdateWorkflowRequest request = @@ -719,79 +452,40 @@ public final OperationFuture updateWorkflowAsync( return updateWorkflowAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates an existing workflow. Running this method has no impact on already running executions * 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: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   UpdateWorkflowRequest request = UpdateWorkflowRequest.newBuilder()
-   *     .setWorkflow(workflow)
-   *     .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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture updateWorkflowAsync( UpdateWorkflowRequest request) { return updateWorkflowOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates an existing workflow. Running this method has no impact on already running executions * 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: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   UpdateWorkflowRequest request = UpdateWorkflowRequest.newBuilder()
-   *     .setWorkflow(workflow)
-   *     .build();
-   *   OperationFuture<Workflow, OperationMetadata> future = workflowsClient.updateWorkflowOperationCallable().futureCall(request);
-   *   // Do something
-   *   Workflow response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable updateWorkflowOperationCallable() { return stub.updateWorkflowOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates an existing workflow. Running this method has no impact on already running executions * 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: - * - *


-   * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
-   *   Workflow workflow = Workflow.newBuilder().build();
-   *   UpdateWorkflowRequest request = UpdateWorkflowRequest.newBuilder()
-   *     .setWorkflow(workflow)
-   *     .build();
-   *   ApiFuture<Operation> 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/WorkflowsSettings.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsSettings.java index a160c792..a7647064 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsSettings.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/WorkflowsSettings.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta; import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; @@ -36,7 +37,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link WorkflowsClient}. * @@ -53,23 +54,23 @@ * *

For example, to set the total timeout of getWorkflow to 30 seconds: * - *

- * 
- * WorkflowsSettings.Builder workflowsSettingsBuilder =
- *     WorkflowsSettings.newBuilder();
+ * 
{@code
+ * WorkflowsSettings.Builder workflowsSettingsBuilder = WorkflowsSettings.newBuilder();
  * workflowsSettingsBuilder
  *     .getWorkflowSettings()
  *     .setRetrySettings(
- *         workflowsSettingsBuilder.getWorkflowSettings().getRetrySettings().toBuilder()
+ *         workflowsSettingsBuilder
+ *             .getWorkflowSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * WorkflowsSettings workflowsSettings = workflowsSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class WorkflowsSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listWorkflows. */ public PagedCallSettings listWorkflowsSettings() { @@ -87,8 +88,6 @@ public UnaryCallSettings createWorkflowSetting } /** Returns the object with the settings used for calls to createWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings createWorkflowOperationSettings() { return ((WorkflowsStubSettings) getStubSettings()).createWorkflowOperationSettings(); @@ -100,8 +99,6 @@ public UnaryCallSettings deleteWorkflowSetting } /** Returns the object with the settings used for calls to deleteWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings deleteWorkflowOperationSettings() { return ((WorkflowsStubSettings) getStubSettings()).deleteWorkflowOperationSettings(); @@ -113,8 +110,6 @@ public UnaryCallSettings updateWorkflowSetting } /** Returns the object with the settings used for calls to updateWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings updateWorkflowOperationSettings() { return ((WorkflowsStubSettings) getStubSettings()).updateWorkflowOperationSettings(); @@ -179,18 +174,15 @@ protected WorkflowsSettings(Builder settingsBuilder) throws IOException { /** Builder for WorkflowsSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(WorkflowsStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(WorkflowsStubSettings.newBuilder()); - } - protected Builder(WorkflowsSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -199,11 +191,15 @@ protected Builder(WorkflowsStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(WorkflowsStubSettings.newBuilder()); + } + public WorkflowsStubSettings.Builder getStubSettingsBuilder() { return ((WorkflowsStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -234,8 +230,6 @@ public UnaryCallSettings.Builder createWorkflo } /** Returns the builder for the settings used for calls to createWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder createWorkflowOperationSettings() { return getStubSettingsBuilder().createWorkflowOperationSettings(); @@ -247,8 +241,6 @@ public UnaryCallSettings.Builder deleteWorkflo } /** Returns the builder for the settings used for calls to deleteWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder deleteWorkflowOperationSettings() { return getStubSettingsBuilder().deleteWorkflowOperationSettings(); @@ -260,8 +252,6 @@ public UnaryCallSettings.Builder updateWorkflo } /** Returns the builder for the settings used for calls to updateWorkflow. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder updateWorkflowOperationSettings() { return getStubSettingsBuilder().updateWorkflowOperationSettings(); 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 f8aedba1..cea98754 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 @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,27 +15,16 @@ */ /** - * A client to Workflows API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

=============== WorkflowsClient =============== + *

======================= WorkflowsClient ======================= * *

Service Description: Workflows is used to deploy and execute workflow programs. Workflows * makes sure the program executes reliably, despite hardware and networking interruptions. * *

Sample for WorkflowsClient: - * - *

- * 
- * try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
- *   WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
- *   Workflow response = workflowsClient.getWorkflow(name);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.workflows.v1beta; import javax.annotation.Generated; diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsCallableFactory.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsCallableFactory.java index 732aaaeb..ea19e425 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsCallableFactory.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsCallableFactory.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Workflows API. + * gRPC callable factory implementation for the Workflows service API. * *

This class is for advanced usage. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public class GrpcWorkflowsCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsStub.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsStub.java index fa8d6fc3..f3b4b971 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsStub.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/GrpcWorkflowsStub.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta.stub; import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -45,16 +45,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Workflows API. + * gRPC stub implementation for the Workflows service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcWorkflowsStub extends WorkflowsStub { - private static final MethodDescriptor listWorkflowsMethodDescriptor = MethodDescriptor.newBuilder() @@ -65,6 +63,7 @@ public class GrpcWorkflowsStub extends WorkflowsStub { .setResponseMarshaller( ProtoUtils.marshaller(ListWorkflowsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getWorkflowMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -72,6 +71,7 @@ public class GrpcWorkflowsStub extends WorkflowsStub { .setRequestMarshaller(ProtoUtils.marshaller(GetWorkflowRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Workflow.getDefaultInstance())) .build(); + private static final MethodDescriptor createWorkflowMethodDescriptor = MethodDescriptor.newBuilder() @@ -81,6 +81,7 @@ public class GrpcWorkflowsStub extends WorkflowsStub { ProtoUtils.marshaller(CreateWorkflowRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteWorkflowMethodDescriptor = MethodDescriptor.newBuilder() @@ -90,6 +91,7 @@ public class GrpcWorkflowsStub extends WorkflowsStub { ProtoUtils.marshaller(DeleteWorkflowRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor updateWorkflowMethodDescriptor = MethodDescriptor.newBuilder() @@ -100,9 +102,6 @@ public class GrpcWorkflowsStub extends WorkflowsStub { .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; - private final UnaryCallable listWorkflowsCallable; private final UnaryCallable listWorkflowsPagedCallable; @@ -117,6 +116,8 @@ public class GrpcWorkflowsStub extends WorkflowsStub { private final OperationCallable updateWorkflowOperationCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcWorkflowsStub create(WorkflowsStubSettings settings) throws IOException { @@ -133,21 +134,11 @@ public static final GrpcWorkflowsStub create( WorkflowsStubSettings.newBuilder().build(), clientContext, callableFactory); } - /** - * Constructs an instance of GrpcWorkflowsStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ protected GrpcWorkflowsStub(WorkflowsStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcWorkflowsCallableFactory()); } - /** - * Constructs an instance of GrpcWorkflowsStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ protected GrpcWorkflowsStub( WorkflowsStubSettings settings, ClientContext clientContext, @@ -239,7 +230,7 @@ public Map extract(UpdateWorkflowRequest request) { createWorkflowTransportSettings, settings.createWorkflowOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.deleteWorkflowCallable = callableFactory.createUnaryCallable( deleteWorkflowTransportSettings, settings.deleteWorkflowSettings(), clientContext); @@ -248,7 +239,7 @@ public Map extract(UpdateWorkflowRequest request) { deleteWorkflowTransportSettings, settings.deleteWorkflowOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.updateWorkflowCallable = callableFactory.createUnaryCallable( updateWorkflowTransportSettings, settings.updateWorkflowSettings(), clientContext); @@ -257,59 +248,56 @@ public Map extract(UpdateWorkflowRequest request) { updateWorkflowTransportSettings, settings.updateWorkflowOperationSettings(), clientContext, - this.operationsStub); + operationsStub); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public GrpcOperationsStub getOperationsStub() { return operationsStub; } + public UnaryCallable listWorkflowsCallable() { + return listWorkflowsCallable; + } + public UnaryCallable listWorkflowsPagedCallable() { return listWorkflowsPagedCallable; } - public UnaryCallable listWorkflowsCallable() { - return listWorkflowsCallable; - } - public UnaryCallable getWorkflowCallable() { return getWorkflowCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public UnaryCallable createWorkflowCallable() { + return createWorkflowCallable; + } + public OperationCallable createWorkflowOperationCallable() { return createWorkflowOperationCallable; } - public UnaryCallable createWorkflowCallable() { - return createWorkflowCallable; + public UnaryCallable deleteWorkflowCallable() { + return deleteWorkflowCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable deleteWorkflowOperationCallable() { return deleteWorkflowOperationCallable; } - public UnaryCallable deleteWorkflowCallable() { - return deleteWorkflowCallable; + public UnaryCallable updateWorkflowCallable() { + return updateWorkflowCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateWorkflowOperationCallable() { return updateWorkflowOperationCallable; } - public UnaryCallable updateWorkflowCallable() { - return updateWorkflowCallable; - } - @Override public final void close() { shutdown(); diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStub.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStub.java index 675445f3..65a32d3e 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStub.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStub.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta.stub; import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -34,17 +34,15 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Workflows API. + * Base stub class for the Workflows service API. * *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class WorkflowsStub implements BackgroundResource { - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } @@ -62,7 +60,6 @@ public UnaryCallable getWorkflowCallable() { throw new UnsupportedOperationException("Not implemented: getWorkflowCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable createWorkflowOperationCallable() { throw new UnsupportedOperationException("Not implemented: createWorkflowOperationCallable()"); @@ -72,7 +69,6 @@ public UnaryCallable createWorkflowCallable() throw new UnsupportedOperationException("Not implemented: createWorkflowCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable deleteWorkflowOperationCallable() { throw new UnsupportedOperationException("Not implemented: deleteWorkflowOperationCallable()"); @@ -82,7 +78,6 @@ public UnaryCallable deleteWorkflowCallable() throw new UnsupportedOperationException("Not implemented: deleteWorkflowCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateWorkflowOperationCallable() { throw new UnsupportedOperationException("Not implemented: updateWorkflowOperationCallable()"); diff --git a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStubSettings.java b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStubSettings.java index bfa79e98..9a31ccd7 100644 --- a/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStubSettings.java +++ b/google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1beta/stub/WorkflowsStubSettings.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta.stub; import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; @@ -62,7 +63,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link WorkflowsStub}. * @@ -79,22 +80,22 @@ * *

For example, to set the total timeout of getWorkflow to 30 seconds: * - *

- * 
- * WorkflowsStubSettings.Builder workflowsSettingsBuilder =
- *     WorkflowsStubSettings.newBuilder();
+ * 
{@code
+ * WorkflowsStubSettings.Builder workflowsSettingsBuilder = WorkflowsStubSettings.newBuilder();
  * workflowsSettingsBuilder
  *     .getWorkflowSettings()
  *     .setRetrySettings(
- *         workflowsSettingsBuilder.getWorkflowSettings().getRetrySettings().toBuilder()
+ *         workflowsSettingsBuilder
+ *             .getWorkflowSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * WorkflowsStubSettings workflowsSettings = workflowsSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class WorkflowsStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -114,6 +115,59 @@ public class WorkflowsStubSettings extends StubSettings { private final OperationCallSettings updateWorkflowOperationSettings; + private static final PagedListDescriptor + LIST_WORKFLOWS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListWorkflowsRequest injectToken(ListWorkflowsRequest payload, String token) { + return ListWorkflowsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListWorkflowsRequest injectPageSize(ListWorkflowsRequest payload, int pageSize) { + return ListWorkflowsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListWorkflowsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListWorkflowsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListWorkflowsResponse payload) { + return payload.getWorkflowsList() == null + ? ImmutableList.of() + : payload.getWorkflowsList(); + } + }; + + private static final PagedListResponseFactory< + ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse> + LIST_WORKFLOWS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListWorkflowsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_WORKFLOWS_PAGE_STR_DESC, request, context); + return ListWorkflowsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to listWorkflows. */ public PagedCallSettings listWorkflowsSettings() { @@ -131,7 +185,6 @@ public UnaryCallSettings createWorkflowSetting } /** Returns the object with the settings used for calls to createWorkflow. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings createWorkflowOperationSettings() { return createWorkflowOperationSettings; @@ -143,7 +196,6 @@ public UnaryCallSettings deleteWorkflowSetting } /** Returns the object with the settings used for calls to deleteWorkflow. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings deleteWorkflowOperationSettings() { return deleteWorkflowOperationSettings; @@ -155,7 +207,6 @@ public UnaryCallSettings updateWorkflowSetting } /** Returns the object with the settings used for calls to updateWorkflow. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings updateWorkflowOperationSettings() { return updateWorkflowOperationSettings; @@ -167,10 +218,10 @@ public WorkflowsStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcWorkflowsStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -239,63 +290,9 @@ protected WorkflowsStubSettings(Builder settingsBuilder) throws IOException { updateWorkflowOperationSettings = settingsBuilder.updateWorkflowOperationSettings().build(); } - private static final PagedListDescriptor - LIST_WORKFLOWS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListWorkflowsRequest injectToken(ListWorkflowsRequest payload, String token) { - return ListWorkflowsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListWorkflowsRequest injectPageSize(ListWorkflowsRequest payload, int pageSize) { - return ListWorkflowsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListWorkflowsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListWorkflowsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListWorkflowsResponse payload) { - return payload.getWorkflowsList() != null - ? payload.getWorkflowsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse> - LIST_WORKFLOWS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListWorkflowsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_WORKFLOWS_PAGE_STR_DESC, request, context); - return ListWorkflowsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - /** Builder for WorkflowsStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final PagedCallSettings.Builder< ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse> listWorkflowsSettings; @@ -312,19 +309,13 @@ public static class Builder extends StubSettings.Builder updateWorkflowOperationSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -333,41 +324,25 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); + settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); + definitions.put("no_retry_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(clientContext); listWorkflowsSettings = PagedCallSettings.newBuilder(LIST_WORKFLOWS_PAGE_STR_FACT); - getWorkflowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - createWorkflowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - createWorkflowOperationSettings = OperationCallSettings.newBuilder(); - deleteWorkflowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteWorkflowOperationSettings = OperationCallSettings.newBuilder(); - updateWorkflowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - updateWorkflowOperationSettings = OperationCallSettings.newBuilder(); unaryMethodSettingsBuilders = @@ -377,52 +352,74 @@ protected Builder(ClientContext clientContext) { createWorkflowSettings, deleteWorkflowSettings, updateWorkflowSettings); - initDefaults(this); } + protected Builder(WorkflowsStubSettings settings) { + super(settings); + + listWorkflowsSettings = settings.listWorkflowsSettings.toBuilder(); + getWorkflowSettings = settings.getWorkflowSettings.toBuilder(); + createWorkflowSettings = settings.createWorkflowSettings.toBuilder(); + createWorkflowOperationSettings = settings.createWorkflowOperationSettings.toBuilder(); + deleteWorkflowSettings = settings.deleteWorkflowSettings.toBuilder(); + deleteWorkflowOperationSettings = settings.deleteWorkflowOperationSettings.toBuilder(); + updateWorkflowSettings = settings.updateWorkflowSettings.toBuilder(); + updateWorkflowOperationSettings = settings.updateWorkflowOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listWorkflowsSettings, + getWorkflowSettings, + createWorkflowSettings, + deleteWorkflowSettings, + updateWorkflowSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - builder .listWorkflowsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .getWorkflowSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .createWorkflowSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .deleteWorkflowSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .updateWorkflowSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + builder .createWorkflowOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Workflow.class)) @@ -431,21 +428,22 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .deleteWorkflowOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) @@ -454,21 +452,22 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .updateWorkflowOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Workflow.class)) @@ -477,40 +476,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); return builder; } - protected Builder(WorkflowsStubSettings settings) { - super(settings); - - listWorkflowsSettings = settings.listWorkflowsSettings.toBuilder(); - getWorkflowSettings = settings.getWorkflowSettings.toBuilder(); - createWorkflowSettings = settings.createWorkflowSettings.toBuilder(); - createWorkflowOperationSettings = settings.createWorkflowOperationSettings.toBuilder(); - deleteWorkflowSettings = settings.deleteWorkflowSettings.toBuilder(); - deleteWorkflowOperationSettings = settings.deleteWorkflowOperationSettings.toBuilder(); - updateWorkflowSettings = settings.updateWorkflowSettings.toBuilder(); - updateWorkflowOperationSettings = settings.updateWorkflowOperationSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listWorkflowsSettings, - getWorkflowSettings, - createWorkflowSettings, - deleteWorkflowSettings, - updateWorkflowSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflows.java b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflows.java index 07c903de..fbb118b8 100644 --- a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflows.java +++ b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflows.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta; import com.google.api.core.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockWorkflows implements MockGrpcService { private final MockWorkflowsImpl serviceImpl; diff --git a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflowsImpl.java b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflowsImpl.java index ffd5087f..58d090f1 100644 --- a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflowsImpl.java +++ b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/MockWorkflowsImpl.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta; import com.google.api.core.BetaApi; @@ -24,9 +25,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockWorkflowsImpl extends WorkflowsImplBase { private List requests; private Queue responses; @@ -63,10 +65,10 @@ public void listWorkflows( Object response = responses.remove(); if (response instanceof ListWorkflowsResponse) { requests.add(request); - responseObserver.onNext((ListWorkflowsResponse) response); + responseObserver.onNext(((ListWorkflowsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -77,10 +79,10 @@ public void getWorkflow(GetWorkflowRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Workflow) { requests.add(request); - responseObserver.onNext((Workflow) response); + responseObserver.onNext(((Workflow) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -92,10 +94,10 @@ public void createWorkflow( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -107,10 +109,10 @@ public void deleteWorkflow( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -122,10 +124,10 @@ public void updateWorkflow( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/WorkflowsClientTest.java b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/WorkflowsClientTest.java index 6bfa8a8d..879df1bb 100644 --- a/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/WorkflowsClientTest.java +++ b/google-cloud-workflows/src/test/java/com/google/cloud/workflows/v1beta/WorkflowsClientTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.workflows.v1beta; import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; @@ -31,13 +32,15 @@ import com.google.protobuf.Any; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import io.grpc.Status; +import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -45,31 +48,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class WorkflowsClientTest { - private static MockWorkflows mockWorkflows; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private WorkflowsClient client; private LocalChannelProvider channelProvider; + private static MockWorkflows mockWorkflows; @BeforeClass public static void startStaticServer() { mockWorkflows = new MockWorkflows(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockWorkflows)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); WorkflowsSettings settings = WorkflowsSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -84,15 +87,12 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listWorkflowsTest() { - String nextPageToken = ""; - Workflow workflowsElement = Workflow.newBuilder().build(); - List workflows = Arrays.asList(workflowsElement); + public void listWorkflowsTest() throws Exception { + Workflow responsesElement = Workflow.newBuilder().build(); ListWorkflowsResponse expectedResponse = ListWorkflowsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllWorkflows(workflows) + .setNextPageToken("") + .addAllWorkflows(Arrays.asList(responsesElement)) .build(); mockWorkflows.addResponse(expectedResponse); @@ -101,14 +101,15 @@ public void listWorkflowsTest() { ListWorkflowsPagedResponse pagedListResponse = client.listWorkflows(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getWorkflowsList().get(0), resources.get(0)); List actualRequests = mockWorkflows.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListWorkflowsRequest actualRequest = (ListWorkflowsRequest) actualRequests.get(0); + ListWorkflowsRequest actualRequest = ((ListWorkflowsRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -116,36 +117,75 @@ public void listWorkflowsTest() { } @Test - @SuppressWarnings("all") public void listWorkflowsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockWorkflows.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listWorkflows(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listWorkflowsTest2() throws Exception { + Workflow responsesElement = Workflow.newBuilder().build(); + ListWorkflowsResponse expectedResponse = + ListWorkflowsResponse.newBuilder() + .setNextPageToken("") + .addAllWorkflows(Arrays.asList(responsesElement)) + .build(); + mockWorkflows.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListWorkflowsPagedResponse pagedListResponse = client.listWorkflows(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getWorkflowsList().get(0), resources.get(0)); + + List actualRequests = mockWorkflows.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListWorkflowsRequest actualRequest = ((ListWorkflowsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listWorkflowsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockWorkflows.addException(exception); + try { + String parent = "parent-995424086"; client.listWorkflows(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getWorkflowTest() { - WorkflowName name2 = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); - String description = "description-1724546052"; - String revisionId = "revisionId513861631"; - String serviceAccount = "serviceAccount-1948028253"; - String sourceContents = "sourceContents-1799875906"; + public void getWorkflowTest() throws Exception { Workflow expectedResponse = Workflow.newBuilder() - .setName(name2.toString()) - .setDescription(description) - .setRevisionId(revisionId) - .setServiceAccount(serviceAccount) - .setSourceContents(sourceContents) + .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString()) + .setDescription("description-1724546052") + .setRevisionId("revision_id513861631") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setServiceAccount("service_account-1948028253") .build(); mockWorkflows.addResponse(expectedResponse); @@ -156,9 +196,9 @@ public void getWorkflowTest() { List actualRequests = mockWorkflows.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetWorkflowRequest actualRequest = (GetWorkflowRequest) actualRequests.get(0); + GetWorkflowRequest actualRequest = ((GetWorkflowRequest) actualRequests.get(0)); - Assert.assertEquals(name, WorkflowName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -166,36 +206,76 @@ public void getWorkflowTest() { } @Test - @SuppressWarnings("all") public void getWorkflowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockWorkflows.addException(exception); try { WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + client.getWorkflow(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getWorkflowTest2() throws Exception { + Workflow expectedResponse = + Workflow.newBuilder() + .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString()) + .setDescription("description-1724546052") + .setRevisionId("revision_id513861631") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setServiceAccount("service_account-1948028253") + .build(); + mockWorkflows.addResponse(expectedResponse); + String name = "name3373707"; + + Workflow actualResponse = client.getWorkflow(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockWorkflows.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetWorkflowRequest actualRequest = ((GetWorkflowRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getWorkflowExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockWorkflows.addException(exception); + + try { + String name = "name3373707"; client.getWorkflow(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void createWorkflowTest() throws Exception { - WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); - String description = "description-1724546052"; - String revisionId = "revisionId513861631"; - String serviceAccount = "serviceAccount-1948028253"; - String sourceContents = "sourceContents-1799875906"; Workflow expectedResponse = Workflow.newBuilder() - .setName(name.toString()) - .setDescription(description) - .setRevisionId(revisionId) - .setServiceAccount(serviceAccount) - .setSourceContents(sourceContents) + .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString()) + .setDescription("description-1724546052") + .setRevisionId("revision_id513861631") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setServiceAccount("service_account-1948028253") .build(); Operation resultOperation = Operation.newBuilder() @@ -207,16 +287,16 @@ public void createWorkflowTest() throws Exception { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Workflow workflow = Workflow.newBuilder().build(); - String workflowId = "workflowId1712917915"; + String workflowId = "workflow_id1712917915"; Workflow actualResponse = client.createWorkflowAsync(parent, workflow, workflowId).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockWorkflows.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateWorkflowRequest actualRequest = (CreateWorkflowRequest) actualRequests.get(0); + CreateWorkflowRequest actualRequest = ((CreateWorkflowRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(workflow, actualRequest.getWorkflow()); Assert.assertEquals(workflowId, actualRequest.getWorkflowId()); Assert.assertTrue( @@ -226,27 +306,83 @@ public void createWorkflowTest() throws Exception { } @Test - @SuppressWarnings("all") public void createWorkflowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockWorkflows.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Workflow workflow = Workflow.newBuilder().build(); - String workflowId = "workflowId1712917915"; + String workflowId = "workflow_id1712917915"; + client.createWorkflowAsync(parent, workflow, workflowId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void createWorkflowTest2() throws Exception { + Workflow expectedResponse = + Workflow.newBuilder() + .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString()) + .setDescription("description-1724546052") + .setRevisionId("revision_id513861631") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setServiceAccount("service_account-1948028253") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createWorkflowTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockWorkflows.addResponse(resultOperation); + String parent = "parent-995424086"; + Workflow workflow = Workflow.newBuilder().build(); + String workflowId = "workflow_id1712917915"; + + Workflow actualResponse = client.createWorkflowAsync(parent, workflow, workflowId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockWorkflows.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateWorkflowRequest actualRequest = ((CreateWorkflowRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(workflow, actualRequest.getWorkflow()); + Assert.assertEquals(workflowId, actualRequest.getWorkflowId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createWorkflowExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockWorkflows.addException(exception); + + try { + String parent = "parent-995424086"; + Workflow workflow = Workflow.newBuilder().build(); + String workflowId = "workflow_id1712917915"; client.createWorkflowAsync(parent, workflow, workflowId).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void deleteWorkflowTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); Operation resultOperation = @@ -259,14 +395,13 @@ public void deleteWorkflowTest() throws Exception { WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); - Empty actualResponse = client.deleteWorkflowAsync(name).get(); - Assert.assertEquals(expectedResponse, actualResponse); + client.deleteWorkflowAsync(name).get(); List actualRequests = mockWorkflows.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteWorkflowRequest actualRequest = (DeleteWorkflowRequest) actualRequests.get(0); + DeleteWorkflowRequest actualRequest = ((DeleteWorkflowRequest) actualRequests.get(0)); - Assert.assertEquals(name, WorkflowName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -274,38 +409,75 @@ public void deleteWorkflowTest() throws Exception { } @Test - @SuppressWarnings("all") public void deleteWorkflowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockWorkflows.addException(exception); try { WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + client.deleteWorkflowAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void deleteWorkflowTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteWorkflowTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockWorkflows.addResponse(resultOperation); + String name = "name3373707"; + + client.deleteWorkflowAsync(name).get(); + + List actualRequests = mockWorkflows.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteWorkflowRequest actualRequest = ((DeleteWorkflowRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteWorkflowExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockWorkflows.addException(exception); + + try { + String name = "name3373707"; client.deleteWorkflowAsync(name).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void updateWorkflowTest() throws Exception { - WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); - String description = "description-1724546052"; - String revisionId = "revisionId513861631"; - String serviceAccount = "serviceAccount-1948028253"; - String sourceContents = "sourceContents-1799875906"; Workflow expectedResponse = Workflow.newBuilder() - .setName(name.toString()) - .setDescription(description) - .setRevisionId(revisionId) - .setServiceAccount(serviceAccount) - .setSourceContents(sourceContents) + .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString()) + .setDescription("description-1724546052") + .setRevisionId("revision_id513861631") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setServiceAccount("service_account-1948028253") .build(); Operation resultOperation = Operation.newBuilder() @@ -323,7 +495,7 @@ public void updateWorkflowTest() throws Exception { List actualRequests = mockWorkflows.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateWorkflowRequest actualRequest = (UpdateWorkflowRequest) actualRequests.get(0); + UpdateWorkflowRequest actualRequest = ((UpdateWorkflowRequest) actualRequests.get(0)); Assert.assertEquals(workflow, actualRequest.getWorkflow()); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); @@ -334,20 +506,18 @@ public void updateWorkflowTest() throws Exception { } @Test - @SuppressWarnings("all") public void updateWorkflowExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockWorkflows.addException(exception); try { Workflow workflow = Workflow.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); - client.updateWorkflowAsync(workflow, updateMask).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } diff --git a/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/LocationName.java b/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/LocationName.java index de22e3e3..aa792b8f 100644 --- a/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/LocationName.java +++ b/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/LocationName.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,19 +23,29 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class LocationName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + public String getProject() { return project; } @@ -52,11 +62,6 @@ public Builder toBuilder() { return new Builder(this); } - private LocationName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - } - public static LocationName of(String project, String location) { return newBuilder().setProject(project).setLocation(location).build(); } @@ -70,7 +75,7 @@ public static LocationName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION.validatedMatch( formattedString, "LocationName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location")); } @@ -84,7 +89,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (LocationName value : values) { if (value == null) { list.add(""); @@ -96,16 +101,21 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,15 +129,39 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "location", location); + return PROJECT_LOCATION.instantiate("project", project, "location", location); } - /** Builder for LocationName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { private String project; private String location; + protected Builder() {} + public String getProject() { return project; } @@ -146,8 +180,6 @@ public Builder setLocation(String location) { return this; } - private Builder() {} - private Builder(LocationName locationName) { project = locationName.project; location = locationName.location; @@ -157,26 +189,4 @@ public LocationName build() { return new LocationName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof LocationName) { - LocationName that = (LocationName) o; - return (this.project.equals(that.project)) && (this.location.equals(that.location)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - return h; - } } diff --git a/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/WorkflowName.java b/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/WorkflowName.java index 04e77584..be7e2369 100644 --- a/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/WorkflowName.java +++ b/proto-google-cloud-workflows-v1beta/src/main/java/com/google/cloud/workflows/v1beta/WorkflowName.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class WorkflowName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_WORKFLOW = PathTemplate.createWithoutUrlEncoding( "projects/{project}/locations/{location}/workflows/{workflow}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String workflow; + @Deprecated + protected WorkflowName() { + project = null; + location = null; + workflow = null; + } + + private WorkflowName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + workflow = Preconditions.checkNotNull(builder.getWorkflow()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private WorkflowName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - workflow = Preconditions.checkNotNull(builder.getWorkflow()); - } - public static WorkflowName of(String project, String location, String workflow) { return newBuilder().setProject(project).setLocation(location).setWorkflow(workflow).build(); } @@ -82,7 +88,7 @@ public static WorkflowName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_WORKFLOW.validatedMatch( formattedString, "WorkflowName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("workflow")); } @@ -96,7 +102,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (WorkflowName value : values) { if (value == null) { list.add(""); @@ -108,17 +114,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_WORKFLOW.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("workflow", workflow); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (workflow != null) { + fieldMapBuilder.put("workflow", workflow); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -132,17 +145,44 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_LOCATION_WORKFLOW.instantiate( "project", project, "location", location, "workflow", workflow); } - /** Builder for WorkflowName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + WorkflowName that = ((WorkflowName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.workflow, that.workflow); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(workflow); + return h; + } + + /** Builder for projects/{project}/locations/{location}/workflows/{workflow}. */ + public static class Builder { private String project; private String location; private String workflow; + protected Builder() {} + public String getProject() { return project; } @@ -170,8 +210,6 @@ public Builder setWorkflow(String workflow) { return this; } - private Builder() {} - private Builder(WorkflowName workflowName) { project = workflowName.project; location = workflowName.location; @@ -182,30 +220,4 @@ public WorkflowName build() { return new WorkflowName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof WorkflowName) { - WorkflowName that = (WorkflowName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.workflow.equals(that.workflow)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= workflow.hashCode(); - return h; - } } diff --git a/synth.metadata b/synth.metadata index 7a005f7c..d396b554 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-workflows.git", - "sha": "6c0d9c40f31cda7c9f6727e2f1d18948b382cffa" + "sha": "a3003c8b601668c0e6b656aebf1fc1476083b4a2" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ba5a928ab823d97dc6b7042ff32130d19b002f75", - "internalRef": "331550506" + "sha": "0a9a8c8a88c1ea9d141ef69fbaeba1ca9dd474ba", + "internalRef": "345495218" } }, {