Python 또는 Ruby를 사용하여 워크플로 업데이트

Python 또는 Ruby를 사용하여 워크플로를 업데이트합니다.

코드 샘플

C#

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

Workflows에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

using Google.Cloud.Workflows.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedWorkflowsClientSnippets
{
    /// <summary>Snippet for UpdateWorkflow</summary>
    /// <remarks>
    /// 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/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void UpdateWorkflowRequestObject()
    {
        // Create client
        WorkflowsClient workflowsClient = WorkflowsClient.Create();
        // Initialize request argument(s)
        UpdateWorkflowRequest request = new UpdateWorkflowRequest
        {
            Workflow = new Workflow(),
            UpdateMask = new FieldMask(),
        };
        // Make the request
        Operation<Workflow, OperationMetadata> response = workflowsClient.UpdateWorkflow(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.PollOnceUpdateWorkflow(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;
        }
    }
}

Go

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

Workflows에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


package main

import (
	"context"

	workflows "cloud.google.com/go/workflows/apiv1"
	workflowspb "cloud.google.com/go/workflows/apiv1/workflowspb"
)

func main() {
	ctx := context.Background()
	// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := workflows.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &workflowspb.UpdateWorkflowRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/workflows/apiv1/workflowspb#UpdateWorkflowRequest.
	}
	op, err := c.UpdateWorkflow(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

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

Java

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

Workflows에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.workflows.v1.UpdateWorkflowRequest;
import com.google.cloud.workflows.v1.Workflow;
import com.google.cloud.workflows.v1.WorkflowsClient;
import com.google.protobuf.FieldMask;

public class SyncUpdateWorkflow {

  public static void main(String[] args) throws Exception {
    syncUpdateWorkflow();
  }

  public static void syncUpdateWorkflow() throws Exception {
    // 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();
    }
  }
}

Python

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

Workflows에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import workflows_v1

def sample_update_workflow():
    # Create a client
    client = workflows_v1.WorkflowsClient()

    # Initialize request argument(s)
    workflow = workflows_v1.Workflow()
    workflow.source_contents = "source_contents_value"

    request = workflows_v1.UpdateWorkflowRequest(
        workflow=workflow,
    )

    # Make the request
    operation = client.update_workflow(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

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

Workflows에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

require "google/cloud/workflows/v1"

##
# Snippet for the update_workflow call in the Workflows service
#
# 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/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Workflows::V1::Workflows::Client#update_workflow.
#
def update_workflow
  # 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::UpdateWorkflowRequest.new

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

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

다음 단계

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