Connector für Storage Transfer Service

Workflow-Connector, der die integrierte Funktion definiert, mit der in einem Workflow auf den Storage Transfer Service zugegriffen wird.

Weitere Informationen

Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:

Codebeispiel

YAML

# This workflow demonstrates how to use the Cloud Storage Transfer Service connector:
# Create source and sink Cloud Storage buckets and then create a transfer job
# that transfers data from the source bucket to the sink bucket
# Run the transfer job and then set the status of the job to "DELETED"
# Expected output: "SUCCESS"
- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - transfer_job_name: "transferJobs/example-transfer-job"
      - src_bucket_name: "SOURCE_BUCKET_NAME"  # replace SOURCE_BUCKET_NAME placeholder
      - sink_bucket_name: "SINK_BUCKET_NAME"  # replace SINK_BUCKET_NAME placeholder
- create_source_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${src_bucket_name}
- create_sink_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${sink_bucket_name}
- create_transfer_job:
    call: googleapis.storagetransfer.v1.transferJobs.create
    args:
      body:
        name: ${transfer_job_name}
        description: "A job that transfers data from source bucket to sink bucket"
        projectId: ${project_id}
        transferSpec:
          gcsDataSink:
            bucketName: ${sink_bucket_name}
            path: ""
          gcsDataSource:
            bucketName: ${src_bucket_name}
            path: ""
        status: "DISABLED"
- enable_transfer_job:
    call: googleapis.storagetransfer.v1.transferJobs.patch
    args:
      jobName: ${transfer_job_name}
      body:
        projectId: ${project_id}
        transferJob:
          status: "ENABLED"
- run_transfer_job:
    call: googleapis.storagetransfer.v1.transferJobs.run
    args:
      jobName: ${transfer_job_name}
      body:
        projectId: ${project_id}
    result: r
- delete_transfer_job:
    # Transfer jobs become eligible for garbage collection 30 days
    # after their status is set to DELETED
    call: googleapis.storagetransfer.v1.transferJobs.patch
    args:
      jobName: ${transfer_job_name}
      body:
        projectId: ${project_id}
        transferJob:
          status: "DELETED"
- the_end:
    return: "SUCCESS"

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.