Delete a workflow

Deletes a workflow.

Code sample

Go

Before trying this sample, follow the Go setup instructions in the Workflows quickstart using client libraries. For more information, see the Workflows Go API reference documentation.


package main

import (
	"context"

	workflows "cloud.google.com/go/workflows/apiv1beta"
	workflowspb "google.golang.org/genproto/googleapis/cloud/workflows/v1beta"
)

func main() {
	ctx := context.Background()
	c, err := workflows.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &workflowspb.DeleteWorkflowRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/workflows/v1beta#DeleteWorkflowRequest.
	}
	op, err := c.DeleteWorkflow(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

Ruby

Before trying this sample, follow the Ruby setup instructions in the Workflows quickstart using client libraries. For more information, see the Workflows Ruby API reference documentation.

require "google/cloud/workflows/v1beta"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Workflows::V1beta::Workflows::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Workflows::V1beta::DeleteWorkflowRequest.new

# Call the delete_workflow method.
result = client.delete_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

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.