워크플로 나열

워크플로를 나열합니다.

코드 샘플

C#

이 샘플을 사용해 보기 전에 Workflows 빠른 시작: 클라이언트 라이브러리 사용의 C# 설정 안내를 따르세요. 자세한 내용은 Workflows C# API 참조 문서를 확인하세요.

using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Workflows.V1Beta;
using System;

public sealed partial class GeneratedWorkflowsClientSnippets
{
    /// <summary>Snippet for ListWorkflows</summary>
    /// <remarks>
    /// This snippet has been automatically generated for illustrative purposes only.
    /// It may require modifications to work in your environment.
    /// </remarks>
    public void ListWorkflowsRequestObject()
    {
        // Create client
        WorkflowsClient workflowsClient = WorkflowsClient.Create();
        // Initialize request argument(s)
        ListWorkflowsRequest request = new ListWorkflowsRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Filter = "",
            OrderBy = "",
        };
        // Make the request
        PagedEnumerable<ListWorkflowsResponse, Workflow> response = workflowsClient.ListWorkflows(request);

        // Iterate over all response items, lazily performing RPCs as required
        foreach (Workflow item in response)
        {
            // Do something with each item
            Console.WriteLine(item);
        }

        // Or iterate over pages (of server-defined size), performing one RPC per page
        foreach (ListWorkflowsResponse page in response.AsRawResponses())
        {
            // Do something with each page of items
            Console.WriteLine("A page of results:");
            foreach (Workflow item in page)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
        }

        // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
        int pageSize = 10;
        Page<Workflow> singlePage = response.ReadPage(pageSize);
        // Do something with the page of items
        Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
        foreach (Workflow item in singlePage)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
        // Store the pageToken, for when the next page is required.
        string nextPageToken = singlePage.NextPageToken;
    }
}

Go

이 샘플을 사용해 보기 전에 Workflows 빠른 시작: 클라이언트 라이브러리 사용의 Go 설정 안내를 따르세요. 자세한 내용은 Workflows Go API 참조 문서를 참조하세요.


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
	}
}

Python

이 샘플을 시도해 보기 전에 Workflows 빠른 시작: 클라이언트 라이브러리 사용의 Python 설정 안내를 따르세요. 자세한 내용은 Workflows Python API 참조 문서를 확인하세요.

from google.cloud import workflows_v1beta

def sample_list_workflows():
    # Create a client
    client = workflows_v1beta.WorkflowsClient()

    # Initialize request argument(s)
    request = workflows_v1beta.ListWorkflowsRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_workflows(request=request)

    # Handle the response
    for response in page_result:
        print(response)

Ruby

이 샘플을 사용해 보기 전에 Workflows 빠른 시작: 클라이언트 라이브러리 사용의 Ruby 설정 안내를 따르세요. 자세한 내용은 Workflows Ruby API 참조 문서를 확인하세요.

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.