목록 나열(v1)

BigQuery Analytics Hub 데이터 교환의 모든 목록을 나열합니다.

코드 샘플

Python

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

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

from google.api_core import exceptions
from google.cloud import bigquery_analyticshub_v1


def list_listings(project_id: str, location_id: str, data_exchange_id: str) -> None:
    """Lists listings in a BigQuery Analytics Hub data exchange.

    Args:
        project_id: The Google Cloud project ID.
        location_id: The Google Cloud region or location for the data exchange (for example, 'us').
        data_exchange_id: The ID of the data exchange.
    """
    client = bigquery_analyticshub_v1.AnalyticsHubServiceClient()

    parent = (
        f"projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"
    )

    request = bigquery_analyticshub_v1.ListListingsRequest(parent=parent)

    try:
        response = client.list_listings(request=request)
        for listing in response:
            print(f"Listing name: {listing.name}")
            print(f"Display name: {listing.display_name}")
    except exceptions.GoogleAPICallError as error:
        print(f"Request failed with API error: {error}")

다음 단계

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