Connecteur pour le service de transfert de stockage

Connecteur de workflows qui définit la fonction intégrée utilisée pour accéder au service de transfert de stockage dans un workflow.

En savoir plus

Pour obtenir une documentation détaillée incluant cet exemple de code, consultez les articles suivants :

Exemple de code

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"

Étapes suivantes

Pour rechercher et filtrer des exemples de code pour d'autres produits Google Cloud, consultez l'explorateur d'exemples Google Cloud.