List workflows

Lists workflows.

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"
	"google.golang.org/api/iterator"
	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.ListWorkflowsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/workflows/v1beta#ListWorkflowsRequest.
	}
	it := c.ListWorkflows(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

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::ListWorkflowsRequest.new

# Call the list_workflows method.
result = client.list_workflows request

# The returned object is of type Gapic::PagedEnumerable. You can
# iterate over all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::Workflows::V1beta::Workflow.
  p response
end

What's next

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