List entries
Stay organized with collections
Save and categorize content based on your preferences.
List existing entries.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code samples in Java and Python for listing existing entries in Google Cloud Dataplex.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples demonstrate how to use the \u003ccode\u003eCatalogServiceClient\u003c/code\u003e to list entries within a specified project, location, and entry group, and includes instructions for setting up authentication.\u003c/p\u003e\n"],["\u003cp\u003eBoth Java and Python samples include the use of filters to specify the type of entries being retrieved.\u003c/p\u003e\n"],["\u003cp\u003eThe page guides users to necessary setup instructions, as well as detailed API documentation for both Java and Python.\u003c/p\u003e\n"],["\u003cp\u003eA link to the Google Cloud sample browser is included for finding additional code samples for other Google Cloud products.\u003c/p\u003e\n"]]],[],null,["# List entries\n\nList existing entries.\n\nCode sample\n-----------\n\n### Java\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Dataplex Universal Catalog quickstart using\nclient libraries](/dataplex/docs/reference/libraries).\n\n\nFor more information, see the\n[Dataplex Universal Catalog Java API\nreference documentation](/java/docs/reference/google-cloud-dataplex/latest/overview).\n\n\nTo authenticate to Dataplex Universal Catalog, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.cloud.dataplex.v1.https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.CatalogServiceClient.html;\n import com.google.cloud.dataplex.v1.https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.Entry.html;\n import com.google.cloud.dataplex.v1.https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.EntryGroupName.html;\n import com.google.cloud.dataplex.v1.https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.ListEntriesRequest.html;\n import com.google.common.collect.ImmutableList;\n import java.io.IOException;\n import java.util.List;\n\n public class ListEntries {\n\n public static void main(String[] args) throws IOException {\n // TODO(developer): Replace these variables before running the sample.\n String projectId = \"MY_PROJECT_ID\";\n // Available locations: https://cloud.google.com/dataplex/docs/locations\n String location = \"MY_LOCATION\";\n String entryGroupId = \"MY_ENTRY_GROUP_ID\";\n\n List\u003cEntry\u003e entries = listEntries(projectId, location, entryGroupId);\n entries.forEach(aspectType -\u003e System.out.println(\"Entry name: \" + aspectType.getName()));\n }\n\n // Method to list Entries located in projectId, location and entryGroupId\n public static List\u003cEntry\u003e listEntries(String projectId, String location, String entryGroupId)\n throws IOException {\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests.\n try (https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.CatalogServiceClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.CatalogServiceClient.html.create()) {\n https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.ListEntriesRequest.html listEntriesRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.ListEntriesRequest.html.newBuilder()\n .setParent(https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.EntryGroupName.html.of(projectId, location, entryGroupId).toString())\n // A filter on the entries to return. Filters are case-sensitive.\n // You can filter the request by the following fields:\n // * entry_type\n // * entry_source.display_name\n // To learn more about filters in general, see:\n // https://cloud.google.com/sdk/gcloud/reference/topic/filters\n .setFilter(\"entry_type=projects/dataplex-types/locations/global/entryTypes/generic\")\n .build();\n https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.CatalogServiceClient.html.https://cloud.google.com/java/docs/reference/google-cloud-dataplex/latest/com.google.cloud.dataplex.v1.CatalogServiceClient.ListEntriesPagedResponse.html listEntriesResponse =\n client.listEntries(listEntriesRequest);\n // Paging is implicitly handled by .iterateAll(), all results will be returned\n return ImmutableList.copyOf(listEntriesResponse.iterateAll());\n }\n }\n }\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Dataplex Universal Catalog quickstart using\nclient libraries](/dataplex/docs/reference/libraries).\n\n\nFor more information, see the\n[Dataplex Universal Catalog Python API\nreference documentation](/python/docs/reference/dataplex/latest).\n\n\nTo authenticate to Dataplex Universal Catalog, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from typing import List\n\n from google.cloud import https://cloud.google.com/python/docs/reference/dataplex/latest/\n\n\n def list_entries(\n project_id: str, location: str, entry_group_id: str\n ) -\u003e List[dataplex_v1.Entry]:\n \"\"\"Method to list Entries located in project_id, location and entry_group_id\"\"\"\n\n # Initialize client that will be used to send requests across threads. This\n # client only needs to be created once, and can be reused for multiple requests.\n # After completing all of your requests, call the \"__exit__()\" method to safely\n # clean up any remaining background resources. Alternatively, use the client as\n # a context manager.\n with https://cloud.google.com/python/docs/reference/dataplex/latest/.https://cloud.google.com/python/docs/reference/dataplex/latest/google.cloud.dataplex_v1.services.catalog_service.CatalogServiceClient.html() as client:\n # The resource name of the Entries location\n parent = (\n f\"projects/{project_id}/locations/{location}/entryGroups/{entry_group_id}\"\n )\n list_entries_request = https://cloud.google.com/python/docs/reference/dataplex/latest/.https://cloud.google.com/python/docs/reference/dataplex/latest/google.cloud.dataplex_v1.types.ListEntriesRequest.html(\n parent=parent,\n # A filter on the entries to return. Filters are case-sensitive.\n # You can filter the request by the following fields:\n # * entry_type\n # * entry_source.display_name\n # To learn more about filters in general, see:\n # https://cloud.google.com/sdk/gcloud/reference/topic/filters\n filter=\"entry_type=projects/dataplex-types/locations/global/entryTypes/generic\",\n )\n\n results = client.list_entries(request=list_entries_request)\n return list(results)\n\n\n if __name__ == \"__main__\":\n # TODO(developer): Replace these variables before running the sample.\n project_id = \"MY_PROJECT_ID\"\n # Available locations: https://cloud.google.com/dataplex/docs/locations\n location = \"MY_LOCATION\"\n entry_group_id = \"MY_ENTRY_GROUP_ID\"\n\n entries = list_entries(project_id, location, entry_group_id)\n for entry in entries:\n print(f\"Entry name: {entry.name}\")\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=dataplex)."]]