com.google.cloud.workflows.v1beta.WorkflowsClient Maven / Gradle / Ivy
Show all versions of google-cloud-workflows Show documentation
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.workflows.v1beta.stub.WorkflowsStub;
import com.google.cloud.workflows.v1beta.stub.WorkflowsStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// 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.
*
* This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* WorkflowName name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]");
* Workflow response = workflowsClient.getWorkflow(name);
* }
* }
*
* Note: close() needs to be called on the WorkflowsClient object to clean up resources such as
* threads. In the example above, try-with-resources is used, which automatically calls close().
*
*
* Methods
*
* Method
* Description
* Method Variants
*
*
* ListWorkflows
* Lists Workflows in a given project and location. The default order is not specified.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listWorkflows(ListWorkflowsRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* listWorkflows(LocationName parent)
*
listWorkflows(String parent)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listWorkflowsPagedCallable()
*
listWorkflowsCallable()
*
*
*
*
* GetWorkflow
* Gets details of a single Workflow.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getWorkflow(GetWorkflowRequest request)
*
* "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
*
* getWorkflow(WorkflowName name)
*
getWorkflow(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getWorkflowCallable()
*
*
*
*
* CreateWorkflow
* 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.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* createWorkflowAsync(CreateWorkflowRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* createWorkflowAsync(LocationName parent, Workflow workflow, String workflowId)
*
createWorkflowAsync(String parent, Workflow workflow, String workflowId)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createWorkflowOperationCallable()
*
createWorkflowCallable()
*
*
*
*
* DeleteWorkflow
* Deletes a workflow with the specified name. This method also cancels and deletes all running executions of the workflow.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* deleteWorkflowAsync(DeleteWorkflowRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* deleteWorkflowAsync(WorkflowName name)
*
deleteWorkflowAsync(String name)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* deleteWorkflowOperationCallable()
*
deleteWorkflowCallable()
*
*
*
*
* UpdateWorkflow
* 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.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* updateWorkflowAsync(UpdateWorkflowRequest request)
*
* Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
*
* updateWorkflowAsync(Workflow workflow, FieldMask updateMask)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateWorkflowOperationCallable()
*
updateWorkflowCallable()
*
*
*
*
*
* See the individual methods for example code.
*
*
Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
*
This class can be customized by passing in a custom instance of WorkflowsSettings to create().
* For example:
*
*
To customize credentials:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* WorkflowsSettings workflowsSettings =
* WorkflowsSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings);
* }
*
* To customize the endpoint:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* WorkflowsSettings workflowsSettings =
* WorkflowsSettings.newBuilder().setEndpoint(myEndpoint).build();
* WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings);
* }
*
* To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* WorkflowsSettings workflowsSettings = WorkflowsSettings.newHttpJsonBuilder().build();
* WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
@Generated("by gapic-generator-java")
public class WorkflowsClient implements BackgroundResource {
private final WorkflowsSettings settings;
private final WorkflowsStub stub;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of WorkflowsClient with default settings. */
public static final WorkflowsClient create() throws IOException {
return create(WorkflowsSettings.newBuilder().build());
}
/**
* Constructs an instance of WorkflowsClient, using the given settings. The channels are created
* based on the settings passed in, or defaults for any settings that are not set.
*/
public static final WorkflowsClient create(WorkflowsSettings settings) throws IOException {
return new WorkflowsClient(settings);
}
/**
* Constructs an instance of WorkflowsClient, using the given stub for making calls. This is for
* advanced usage - prefer using create(WorkflowsSettings).
*/
public static final WorkflowsClient create(WorkflowsStub stub) {
return new WorkflowsClient(stub);
}
/**
* Constructs an instance of WorkflowsClient, 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 WorkflowsClient(WorkflowsSettings settings) throws IOException {
this.settings = settings;
this.stub = ((WorkflowsStubSettings) settings.getStubSettings()).createStub();
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected WorkflowsClient(WorkflowsStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final WorkflowsSettings getSettings() {
return settings;
}
public WorkflowsStub getStub() {
return stub;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
@BetaApi
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists Workflows in a given project and location. The default order is not specified.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final ListWorkflowsPagedResponse listWorkflows(LocationName parent) {
ListWorkflowsRequest request =
ListWorkflowsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.build();
return listWorkflows(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists Workflows in a given project and location. The default order is not specified.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* for (Workflow element : workflowsClient.listWorkflows(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param parent Required. Project and location from which the workflows should be listed. Format:
* projects/{project}/locations/{location}
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListWorkflowsPagedResponse listWorkflows(String parent) {
ListWorkflowsRequest request = ListWorkflowsRequest.newBuilder().setParent(parent).build();
return listWorkflows(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists Workflows in a given project and location. The default order is not specified.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* ListWorkflowsRequest request =
* ListWorkflowsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* for (Workflow element : workflowsClient.listWorkflows(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListWorkflowsPagedResponse listWorkflows(ListWorkflowsRequest request) {
return listWorkflowsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists Workflows in a given project and location. The default order is not specified.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* ListWorkflowsRequest request =
* ListWorkflowsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* ApiFuture future = workflowsClient.listWorkflowsPagedCallable().futureCall(request);
* // Do something.
* for (Workflow element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listWorkflowsPagedCallable() {
return stub.listWorkflowsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists Workflows in a given project and location. The default order is not specified.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* ListWorkflowsRequest request =
* ListWorkflowsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .setOrderBy("orderBy-1207110587")
* .build();
* 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.
/**
* Gets details of a single Workflow.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final Workflow getWorkflow(WorkflowName name) {
GetWorkflowRequest request =
GetWorkflowRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return getWorkflow(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets details of a single Workflow.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* String name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
* Workflow response = workflowsClient.getWorkflow(name);
* }
* }
*
* @param name Required. Name of the workflow which information should be retrieved. Format:
* projects/{project}/locations/{location}/workflows/{workflow}
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Workflow getWorkflow(String name) {
GetWorkflowRequest request = GetWorkflowRequest.newBuilder().setName(name).build();
return getWorkflow(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets details of a single Workflow.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* GetWorkflowRequest request =
* GetWorkflowRequest.newBuilder()
* .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
* .build();
* Workflow response = workflowsClient.getWorkflow(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Workflow getWorkflow(GetWorkflowRequest request) {
return getWorkflowCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets details of a single Workflow.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* GetWorkflowRequest request =
* GetWorkflowRequest.newBuilder()
* .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
* .build();
* ApiFuture future = workflowsClient.getWorkflowCallable().futureCall(request);
* // Do something.
* Workflow response = future.get();
* }
* }
*/
public final UnaryCallable getWorkflowCallable() {
return stub.getWorkflowCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* Workflow workflow = Workflow.newBuilder().build();
* String workflowId = "workflowId-360387270";
* Workflow response = workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
* }
* }
*
* @param parent Required. Project and location in which the workflow should be created. Format:
* projects/{project}/locations/{location}
* @param workflow Required. Workflow to be created.
* @param workflowId 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.
*
*
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createWorkflowAsync(
LocationName parent, Workflow workflow, String workflowId) {
CreateWorkflowRequest request =
CreateWorkflowRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setWorkflow(workflow)
.setWorkflowId(workflowId)
.build();
return createWorkflowAsync(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* Workflow workflow = Workflow.newBuilder().build();
* String workflowId = "workflowId-360387270";
* Workflow response = workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
* }
* }
*
* @param parent Required. Project and location in which the workflow should be created. Format:
* projects/{project}/locations/{location}
* @param workflow Required. Workflow to be created.
* @param workflowId 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.
*
*
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createWorkflowAsync(
String parent, Workflow workflow, String workflowId) {
CreateWorkflowRequest request =
CreateWorkflowRequest.newBuilder()
.setParent(parent)
.setWorkflow(workflow)
.setWorkflowId(workflowId)
.build();
return createWorkflowAsync(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* CreateWorkflowRequest request =
* CreateWorkflowRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setWorkflow(Workflow.newBuilder().build())
* .setWorkflowId("workflowId-360387270")
* .build();
* Workflow response = workflowsClient.createWorkflowAsync(request).get();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture createWorkflowAsync(
CreateWorkflowRequest request) {
return createWorkflowOperationCallable().futureCall(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* CreateWorkflowRequest request =
* CreateWorkflowRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setWorkflow(Workflow.newBuilder().build())
* .setWorkflowId("workflowId-360387270")
* .build();
* OperationFuture future =
* workflowsClient.createWorkflowOperationCallable().futureCall(request);
* // Do something.
* Workflow response = future.get();
* }
* }
*/
public final OperationCallable
createWorkflowOperationCallable() {
return stub.createWorkflowOperationCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* CreateWorkflowRequest request =
* CreateWorkflowRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setWorkflow(Workflow.newBuilder().build())
* .setWorkflowId("workflowId-360387270")
* .build();
* ApiFuture future = workflowsClient.createWorkflowCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable createWorkflowCallable() {
return stub.createWorkflowCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
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.
/**
* Deletes a workflow with the specified name. This method also cancels and deletes all running
* executions of the workflow.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* String name = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString();
* workflowsClient.deleteWorkflowAsync(name).get();
* }
* }
*
* @param name Required. Name of the workflow to be deleted. Format:
* projects/{project}/locations/{location}/workflows/{workflow}
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteWorkflowAsync(String name) {
DeleteWorkflowRequest request = DeleteWorkflowRequest.newBuilder().setName(name).build();
return deleteWorkflowAsync(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* DeleteWorkflowRequest request =
* DeleteWorkflowRequest.newBuilder()
* .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
* .build();
* workflowsClient.deleteWorkflowAsync(request).get();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture deleteWorkflowAsync(
DeleteWorkflowRequest request) {
return deleteWorkflowOperationCallable().futureCall(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* DeleteWorkflowRequest request =
* DeleteWorkflowRequest.newBuilder()
* .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
* .build();
* OperationFuture future =
* workflowsClient.deleteWorkflowOperationCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final OperationCallable
deleteWorkflowOperationCallable() {
return stub.deleteWorkflowOperationCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* DeleteWorkflowRequest request =
* DeleteWorkflowRequest.newBuilder()
* .setName(WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]").toString())
* .build();
* ApiFuture future = workflowsClient.deleteWorkflowCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable deleteWorkflowCallable() {
return stub.deleteWorkflowCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* Workflow workflow = Workflow.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* Workflow response = workflowsClient.updateWorkflowAsync(workflow, updateMask).get();
* }
* }
*
* @param workflow Required. Workflow to be updated.
* @param updateMask List of fields to be updated. If not present, the entire workflow will be
* updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture updateWorkflowAsync(
Workflow workflow, FieldMask updateMask) {
UpdateWorkflowRequest request =
UpdateWorkflowRequest.newBuilder().setWorkflow(workflow).setUpdateMask(updateMask).build();
return updateWorkflowAsync(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* UpdateWorkflowRequest request =
* UpdateWorkflowRequest.newBuilder()
* .setWorkflow(Workflow.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* Workflow response = workflowsClient.updateWorkflowAsync(request).get();
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture updateWorkflowAsync(
UpdateWorkflowRequest request) {
return updateWorkflowOperationCallable().futureCall(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* UpdateWorkflowRequest request =
* UpdateWorkflowRequest.newBuilder()
* .setWorkflow(Workflow.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* OperationFuture future =
* workflowsClient.updateWorkflowOperationCallable().futureCall(request);
* // Do something.
* Workflow response = future.get();
* }
* }
*/
public final OperationCallable
updateWorkflowOperationCallable() {
return stub.updateWorkflowOperationCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (WorkflowsClient workflowsClient = WorkflowsClient.create()) {
* UpdateWorkflowRequest request =
* UpdateWorkflowRequest.newBuilder()
* .setWorkflow(Workflow.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future = workflowsClient.updateWorkflowCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable updateWorkflowCallable() {
return stub.updateWorkflowCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListWorkflowsPagedResponse
extends AbstractPagedListResponse<
ListWorkflowsRequest,
ListWorkflowsResponse,
Workflow,
ListWorkflowsPage,
ListWorkflowsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListWorkflowsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListWorkflowsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListWorkflowsPagedResponse(ListWorkflowsPage page) {
super(page, ListWorkflowsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListWorkflowsPage
extends AbstractPage<
ListWorkflowsRequest, ListWorkflowsResponse, Workflow, ListWorkflowsPage> {
private ListWorkflowsPage(
PageContext context,
ListWorkflowsResponse response) {
super(context, response);
}
private static ListWorkflowsPage createEmptyPage() {
return new ListWorkflowsPage(null, null);
}
@Override
protected ListWorkflowsPage createPage(
PageContext context,
ListWorkflowsResponse response) {
return new ListWorkflowsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListWorkflowsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListWorkflowsRequest,
ListWorkflowsResponse,
Workflow,
ListWorkflowsPage,
ListWorkflowsFixedSizeCollection> {
private ListWorkflowsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListWorkflowsFixedSizeCollection createEmptyCollection() {
return new ListWorkflowsFixedSizeCollection(null, 0);
}
@Override
protected ListWorkflowsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListWorkflowsFixedSizeCollection(pages, collectionSize);
}
}
}