הצגת רשימה של מינויים למשאבים משותפים (גרסה 1)

הצגת רשימה של כל המינויים למשאבים משותפים של חילופי נתונים.

דוגמת קוד

Java

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי הוראות ההגדרה של Java במדריך למתחילים של BigQuery באמצעות ספריות לקוח. למידע נוסף, קראו את מאמרי העזרה של BigQuery Java API.

כדי לבצע אימות ב-BigQuery, צריך להגדיר את Application Default Credentials. למידע נוסף, ראו הגדרת אימות לספריות לקוח.

import com.google.cloud.bigquery.analyticshub.v1.AnalyticsHubServiceClient;
import com.google.cloud.bigquery.analyticshub.v1.DataExchangeName;
import com.google.cloud.bigquery.analyticshub.v1.ListSharedResourceSubscriptionsRequest;
import com.google.cloud.bigquery.analyticshub.v1.Subscription;
import java.io.IOException;

public class ListSharedResourceSubscriptions {

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

  public static void listSharedResourceSubscriptions(
      String projectId, String locationId, String dataExchangeId) throws IOException {
    // Initialize the client. Create once and reuse across requests.
    try (AnalyticsHubServiceClient client = AnalyticsHubServiceClient.create()) {
      String resource = DataExchangeName.of(projectId, locationId, dataExchangeId).toString();

      ListSharedResourceSubscriptionsRequest request =
          ListSharedResourceSubscriptionsRequest.newBuilder()
              .setResource(resource)
              .build();

      for (Subscription subscription : client.listSharedResourceSubscriptions(request).iterateAll()) {
        System.out.println("Shared resource subscription: " + subscription.getName());
      }
    }
  }
}

המאמרים הבאים

כדי לחפש ולסנן דוגמאות קוד למוצרים אחרים של Google Cloud , ראו דפדפן לדוגמה שלGoogle Cloud .