Create entry group
Stay organized with collections
Save and categorize content based on your preferences.
Create an entry group.
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 document provides code samples in Java and Node.js for creating an entry group within Google Cloud Data Catalog.\u003c/p\u003e\n"],["\u003cp\u003eThe Java code sample demonstrates how to initialize a \u003ccode\u003eDataCatalogClient\u003c/code\u003e, build an \u003ccode\u003eEntryGroup\u003c/code\u003e object, and create the entry group using a \u003ccode\u003eCreateEntryGroupRequest\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe Node.js sample shows how to construct an \u003ccode\u003eEntryGroup\u003c/code\u003e object, define an \u003ccode\u003eentryGroupRequest\u003c/code\u003e, and use the client to send the API request for entry group creation.\u003c/p\u003e\n"],["\u003cp\u003eBoth samples require setting up Application Default Credentials for authentication and reference the Data Catalog quickstart guide for initial setup instructions.\u003c/p\u003e\n"],["\u003cp\u003eThe document also provides links to the Data Catalog API reference documentation for both Java and Node.js and the Google Cloud sample browser for other cloud products.\u003c/p\u003e\n"]]],[],null,["# Create entry group\n\nCreate an entry group.\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.CreateEntryGroupRequest.html;\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.EntryGroup.html;\n import com.google.cloud.datacatalog.v1.https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.LocationName.html;\n import java.io.IOException;\n\n // Sample to create an entry group\n public class CreateEntryGroup {\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 = \"us-central1\";\n String entryGroupId = \"MY_ENTRY_GROUP_ID\";\n createEntryGroup(projectId, location, entryGroupId);\n }\n\n // Create Entry Group.\n public static void createEntryGroup(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. 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 dataCatalogClient = 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.EntryGroup.html entryGroup =\n https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.EntryGroup.html.newBuilder()\n .setDisplayName(\"MY Entry Group\")\n .setDescription(\"This Entry Group consists of ....\")\n .build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.CreateEntryGroupRequest.html entryGroupRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.CreateEntryGroupRequest.html.newBuilder()\n .setParent(https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.LocationName.html.of(projectId, location).toString())\n .https://cloud.google.com/java/docs/reference/google-cloud-datacatalog/latest/com.google.cloud.datacatalog.v1.CreateEntryGroupRequest.Builder.html#com_google_cloud_datacatalog_v1_CreateEntryGroupRequest_Builder_setEntryGroupId_java_lang_String_(entryGroupId)\n .setEntryGroup(entryGroup)\n .build();\n\n dataCatalogClient.createEntryGroup(entryGroupRequest);\n System.out.println(\"Entry Group created successfully\");\n }\n }\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js 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 Node.js API\nreference documentation](https://googleapis.dev/nodejs/datacatalog/latest/index.html).\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 // -------------------------------\n // Import required modules.\n // -------------------------------\n const {DataCatalogClient} = require('https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html').v1;\n const datacatalog = new https://cloud.google.com/nodejs/docs/reference/datacatalog/latest/overview.html();\n\n // Currently, Data Catalog stores metadata in the\n // us-central1 region.\n const location = 'us-central1';\n\n // TODO(developer): Uncomment the following lines before running the sample.\n // const projectId = 'my-project'\n // const entryGroupId = 'my-entry-group'\n\n // Create an Entry Group.\n // Construct the EntryGroup for the EntryGroup request.\n const entryGroup = {\n displayName: 'My Fileset Entry Group',\n description: 'This Entry Group consists of ....',\n };\n\n // Construct the EntryGroup request to be sent by the client.\n const entryGroupRequest = {\n parent: datacatalog.locationPath(projectId, location),\n entryGroupId,\n entryGroup,\n };\n\n // Use the client to send the API request.\n const [response] = await datacatalog.createEntryGroup(entryGroupRequest);\n\n console.log(response);\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)."]]