Delete a transfer configuration

Permanently delete a transfer configuration, stopping any future runs.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.api.gax.rpc.ApiException;importcom.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient;importcom.google.cloud.bigquery.datatransfer.v1.DeleteTransferConfigRequest;importjava.io.IOException;// Sample to delete a transfer configpublicclassDeleteTransferConfig{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.// i.e projects/{project_id}/transferConfigs/{config_id}` or// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`StringconfigId="MY_CONFIG_ID";deleteTransferConfig(configId);}publicstaticvoiddeleteTransferConfig(StringconfigId)throwsIOException{try(DataTransferServiceClientdataTransferServiceClient=DataTransferServiceClient.create()){DeleteTransferConfigRequestrequest=DeleteTransferConfigRequest.newBuilder().setName(configId).build();dataTransferServiceClient.deleteTransferConfig(request);System.out.println("Transfer config deleted successfully");}catch(ApiExceptionex){System.out.println("Transfer config was not deleted."+ex.toString());}}}

Node.js

Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

const{DataTransferServiceClient,}=require('@google-cloud/bigquery-data-transfer');const{status}=require('@grpc/grpc-js');constclient=newDataTransferServiceClient();/** * Deletes a data transfer configuration. * This sample demonstrates how to delete a transfer configuration, which also * removes its associated transfer runs and logs. * * @param {string} projectId Your Google Cloud project ID, for example 'example-project-id' * @param {string} location The BigQuery location, for example 'us-central1' * @param {string} configId The transfer configuration ID, for example '1234a567-b89c-12d3-45e6-f789g01h23i4' */asyncfunctiondeleteTransferConfig(projectId,location,configId){constname=client.projectLocationTransferConfigPath(projectId,location,configId,);constrequest={name,};try{awaitclient.deleteTransferConfig(request);console.log(`Transfer config deleted '${configId}'`);}catch(err){if(err.code===status.NOT_FOUND){console.error(`Transfer config '${configId}' not found.`);}else{console.error(`Error deleting transfer config '${configId}':`,err);}}}

Python

Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importgoogle.api_core.exceptionsfromgoogle.cloudimportbigquery_datatransfertransfer_client=bigquery_datatransfer.DataTransferServiceClient()transfer_config_name="projects/1234/locations/us/transferConfigs/abcd"try:transfer_client.delete_transfer_config(name=transfer_config_name)exceptgoogle.api_core.exceptions.NotFound:print("Transfer config not found.")else:print(f"Deleted transfer config:{transfer_config_name}")

What's next

To search and filter code samples for other Google Cloud products, see theGoogle Cloud sample browser.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.