목록 삭제(v1)

데이터 교환에서 기존 목록을 삭제합니다.

코드 샘플

Java

이 샘플을 사용해 보기 전에 BigQuery 빠른 시작: 클라이언트 라이브러리 사용의 Java 설정 안내를 따르세요. 자세한 내용은 BigQuery Java API 참고 문서를 확인하세요.

BigQuery에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 클라이언트 라이브러리의 인증 설정을 참조하세요.

import com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubServiceClient;
import com.google.cloud.bigquery.analyticshub.v1.ListingName;
import java.io.IOException;

public class DeleteListing {

  public static void main(String[] args) throws IOException {
    String projectId = "example-project-id";
    String locationId = "example-location-id";
    String dataExchangeId = "example-data-exchange-id";
    String listingId = "example-listing-id";
    deleteListing(projectId, locationId, dataExchangeId, listingId);
  }

  public static void deleteListing(
      String projectId, String locationId, String dataExchangeId, String listingId)
      throws IOException {
    try (AnalyticsHubServiceClient client = AnalyticsHubServiceClient.create()) {
      String name = ListingName.of(projectId, locationId, dataExchangeId, listingId).toString();
      client.deleteListing(name);
      System.out.println("Listing deleted successfully: " + name);
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 BigQuery 빠른 시작: 클라이언트 라이브러리 사용의 Node.js 설정 안내를 따르세요. 자세한 내용은 BigQuery Node.js API 참고 문서를 확인하세요.

BigQuery에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 클라이언트 라이브러리의 인증 설정을 참조하세요.

'use strict';

const {AnalyticsHubServiceClient} = require('@google-cloud/bigquery-analyticshub');
const {status} = require('@grpc/grpc-js');

const client = new AnalyticsHubServiceClient();

/**
 * Deletes a listing from a data exchange.
 *
 * @param {string} projectId - The Google Cloud project ID.
 * @param {string} locationId - The geographic location of the listing and data exchange (for example, 'us' or 'us-central1').
 * @param {string} dataExchangeId - The caller-specified ID of the parent data exchange.
 * @param {string} listingId - The caller-specified ID of the listing to delete.
 */
async function deleteListing(projectId, locationId, dataExchangeId, listingId) {
  const name = `projects/${projectId}/locations/${locationId}/dataExchanges/${dataExchangeId}/listings/${listingId}`;

  try {
    const request = {
      name,
    };

    await client.deleteListing(request);
    console.log(`Deleted listing: ${name}`);
  } catch (err) {
    if (err.code === status.NOT_FOUND) {
      console.error(`Listing not found: ${name}`);
    } else {
      console.error(`Failed to delete listing: ${err.message}`);
    }
  }
}

module.exports = { deleteListing };

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기