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 Java code sample demonstrates how to list existing entries within a specified entry group in Google Cloud Data Catalog.\u003c/p\u003e\n"],["\u003cp\u003eThe code requires setting up Application Default Credentials for authentication and utilizes the Data Catalog client library.\u003c/p\u003e\n"],["\u003cp\u003eThe sample uses variables for project ID, location, and entry group ID, which need to be replaced with your actual project details.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elistEntries\u003c/code\u003e function iterates through and prints the names of all entries within the designated entry group by utilizing \u003ccode\u003eDataCatalogClient.ListEntriesPagedResponse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsers are directed to the Data Catalog quickstart guide and the Java API reference for further setup and information.\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[Data Catalog quickstart using\nclient libraries](/data-catalog/docs/reference/libraries).\n\n\nFor more information, see the\n[Data Catalog Java API\nreference documentation](https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/overview).\n\n\nTo authenticate to Data 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.datacatalog.v1.https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.DataCatalogClient.html;\n import com.google.cloud.datacatalog.v1.https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.EntryGroupName.html;\n import java.io.IOException;\n\n // Sample to get list of entries\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 String location = \"MY_LOCATION\";\n String entryGroupId = \"MY_ENTRY_GROUP_ID\";\n https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.EntryGroupName.html entryGroupName = https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.EntryGroupName.html.of(projectId, location, entryGroupId);\n listEntries(entryGroupName);\n }\n\n public static void listEntries(https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.EntryGroupName.html entryGroupName) 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. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.DataCatalogClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.DataCatalogClient.html.create()) {\n https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.DataCatalogClient.html.https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.DataCatalogClient.ListEntriesPagedResponse.html listEntries = client.listEntries(entryGroupName);\n listEntries\n .iterateAll()\n .forEach(\n entry -\u003e {\n System.out.println(\"Entry name : \" + entry.getName());\n });\n }\n }\n }\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=data_catalog)."]]