适用于 Storage Transfer Service 的连接器

定义用于在工作流内访问 Storage Transfer Service 的内置函数的 Workflows 连接器。

包含此代码示例的文档页面

如需查看上下文中使用的代码示例,请参阅以下文档:

代码示例

YAML

# This workflow demonstrates how to use the Cloud Storage Transfer connector.
# The workflow creates a storage transfer job that transfers data between two buckets,
# runs the job, and deletes the job.
# Expected successful output: "SUCCESS"

- init:
    assign:
    - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
    - transferjob_name: "transferJobs/dummy-transfer-job"
    - src_bucket_name: "[fill in with the source bucket name]"
    - sink_bucket_name: "[fill in with the destination bucket name]"
- create_transferjob:
    call: googleapis.storagetransfer.v1.transferJobs.create
    args:
      body:
        name: ${transferjob_name}
        description: "A job that transfers data between src and sink buckets."
        projectId: ${project_id}
        transferSpec:
          gcsDataSink:
            bucketName: ${sink_bucket_name}
            path: ""
          gcsDataSource:
            bucketName: ${src_bucket_name}
            path: ""
        status: "DISABLED"
- enable_transferjob:
    call: googleapis.storagetransfer.v1.transferJobs.patch
    args:
      jobName: ${transferjob_name}
      body:
        projectId: ${project_id}
        transferJob:
          status: "ENABLED"
- run_job:
    call: googleapis.storagetransfer.v1.transferJobs.run
    args:
      jobName: ${transferjob_name}
      body:
        projectId: ${project_id}
    result: r
- delete_transferjob:
    # After a transfer job is set to this state, the job and all
    # the transfer executions are subject to garbage collection.
    # Transfer jobs become eligible for garbage collection 30 days
    # after their status is set to DELETED.
    call: googleapis.storagetransfer.v1.transferJobs.patch
    args:
      jobName: ${transferjob_name}
      body:
        projectId: ${project_id}
        transferJob:
          status: "DELETED"
- the_end:
    return: "SUCCESS"# then deletes the job.

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器