Conector para el Servicio de transferencia de almacenamiento

Es un conector de flujos de trabajo que define la función integrada que se usa para acceder al Servicio de transferencia de almacenamiento dentro de un flujo de trabajo.

Explora más

Para obtener documentación en la que se incluye esta muestra de código, consulta lo siguiente:

Muestra de código

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"

¿Qué sigue?

Para buscar y filtrar muestras de código para otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.