Menghapus operasi transfer

Menghapus proses transfer di BigQuery Data Transfer Service.

Contoh kode

Node.js

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai BigQuery menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi BigQuery Node.js API.

Untuk melakukan autentikasi ke BigQuery, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk library klien.

const {
  DataTransferServiceClient,
} = require('@google-cloud/bigquery-data-transfer');
const {status} = require('@grpc/grpc-js');

const client = new DataTransferServiceClient();

/**
 * Deletes a transfer run.
 * This action removes a specific execution instance of a transfer configuration.
 *
 * @param {string} projectId The Google Cloud project ID (for example, 'example-project-id').
 * @param {string} location The location of the transfer config (for example, 'us-central1').
 * @param {string} transferConfigId The ID of the transfer configuration (for example, '1234a123-123a-123a-123a-123456789abc').
 * @param {string} runId The ID of the transfer run (for example, '9876b987-987b-987b-987b-987654321cba').
 */
async function deleteTransferRun(
  projectId,
  location = 'us-central1',
  transferConfigId = '1234a123-123a-123a-123a-123456789abc',
  runId = '9876b987-987b-987b-987b-987654321cba',
) {
  const name = client.projectLocationTransferConfigRunPath(
    projectId,
    location,
    transferConfigId,
    runId,
  );
  const request = {
    name,
  };

  try {
    await client.deleteTransferRun(request);
    console.log(`Deleted transfer run ${name}.`);
  } catch (err) {
    if (err.code === status.NOT_FOUND) {
      console.error(`Transfer run ${name} not found.`);
    } else {
      console.error('Error deleting transfer run:', err);
    }
  }
}

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contohGoogle Cloud .