google-cloud-platformgoogle-cloud-data-transfer

How to delete a GCP storage transfer job in python


I want to create a small python program (Cloud Functions) to create, run and delete a few GCP storage transfer services.

I can create a GCP storage transfer job as follows,

from google.cloud import storage_transfer

transfer_job_request = storage_transfer.CreateTransferJobRequest({
    'transfer_job': {
        'project_id': project_id,
        'status': storage_transfer.TransferJob.Status.ENABLED,
        'transfer_spec': {
            'gcs_data_source': {
                'bucket_name': 'source-bucket-name',
            },
            'gcs_data_sink': {
                'bucket_name': 'sink-bucket-name',
            }
        }
    }
})

However, I can not find any apis to delete a GCP storage tansfer job in either Google api or python library documents.

How to delete a GCP storage tansfer job programmably ?

Thanks.


Solution

  • Resolved.

    I found update_transfer_job (patch API) method, which can change a job status to DELETED.