Eintragsgruppe abrufen

Rufen Sie eine vorhandene Eintragsgruppe ab.

Codebeispiel

Java

Folgen Sie der Java Einrichtungsanleitung in der Kurzanleitung zu Knowledge Catalog mit Clientbibliotheken, bevor Sie dieses Beispiel anwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Knowledge Catalog Java API.

Richten Sie zur Authentifizierung bei Knowledge Catalog die Standardanmeldedaten für Anwendungen (ADC) ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.EntryGroup;
import com.google.cloud.dataplex.v1.EntryGroupName;
import java.io.IOException;

public class GetEntryGroup {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "MY_PROJECT_ID";
    // Available locations: https://cloud.google.com/dataplex/docs/locations
    String location = "MY_LOCATION";
    String entryGroupId = "MY_ENTRY_GROUP_ID";

    EntryGroup entryGroup = getEntryGroup(projectId, location, entryGroupId);
    System.out.println("Entry group retrieved successfully: " + entryGroup.getName());
  }

  // Method to retrieve Entry Group located in projectId, location and with entryGroupId
  public static EntryGroup getEntryGroup(String projectId, String location, String entryGroupId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (CatalogServiceClient client = CatalogServiceClient.create()) {
      EntryGroupName entryGroupName = EntryGroupName.of(projectId, location, entryGroupId);
      return client.getEntryGroup(entryGroupName);
    }
  }
}

Python

Folgen Sie der Python Einrichtungsanleitung in der Kurzanleitung zu Knowledge Catalog mit Clientbibliotheken, bevor Sie dieses Beispiel anwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Knowledge Catalog Python API.

Richten Sie zur Authentifizierung bei Knowledge Catalog die Standardanmeldedaten für Anwendungen (ADC) ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

from google.cloud import dataplex_v1


def get_entry_group(
    project_id: str, location: str, entry_group_id: str
) -> dataplex_v1.EntryGroup:
    """Method to retrieve Entry Group located in project_id, location and with entry_group_id"""

    # Initialize client that will be used to send requests across threads. This
    # client only needs to be created once, and can be reused for multiple requests.
    # After completing all of your requests, call the "__exit__()" method to safely
    # clean up any remaining background resources. Alternatively, use the client as
    # a context manager.
    with dataplex_v1.CatalogServiceClient() as client:
        # The resource name of the Entry Type
        name = (
            f"projects/{project_id}/locations/{location}/entryGroups/{entry_group_id}"
        )
        return client.get_entry_group(name=name)


if __name__ == "__main__":
    # TODO(developer): Replace these variables before running the sample.
    project_id = "MY_PROJECT_ID"
    # Available locations: https://cloud.google.com/dataplex/docs/locations
    location = "MY_LOCATION"
    entry_group_id = "MY_ENTRY_GROUP_ID"

    entry_group = get_entry_group(project_id, location, entry_group_id)
    print(f"Entry group retrieved successfully: {entry_group.name}")

Weitere Informationen

Wenn Sie nach Codebeispielen für andere Produkte von Google Cloud suchen und filtern möchten, können Sie den Beispielbrowser fürGoogle Cloud verwenden.