using Google.Api.Gax.ResourceNames;
using Google.Cloud.Workflows.V1;
using Google.LongRunning;
public sealed partial class GeneratedWorkflowsClientSnippets
{
/// <summary>Snippet for CreateWorkflow</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void CreateWorkflowRequestObject()
{
// Create client
WorkflowsClient workflowsClient = WorkflowsClient.Create();
// Initialize request argument(s)
CreateWorkflowRequest request = new CreateWorkflowRequest
{
ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
Workflow = new Workflow(),
WorkflowId = "",
};
// Make the request
Operation<Workflow, OperationMetadata> response = workflowsClient.CreateWorkflow(request);
// Poll until the returned long-running operation is complete
Operation<Workflow, OperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Workflow result = completedResponse.Result;
// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Workflow, OperationMetadata> retrievedResponse = workflowsClient.PollOnceCreateWorkflow(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
Workflow retrievedResult = retrievedResponse.Result;
}
}
}
require "google/cloud/workflows/v1"
# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Workflows::V1::Workflows::Client.new
# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Workflows::V1::CreateWorkflowRequest.new
# Call the create_workflow method.
result = client.create_workflow request
# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
result.wait_until_done! timeout: 60
if result.response?
p result.response
else
puts "Error!"
end