MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

datacatalog/snippets/createCustomEntry.js:17–189  ·  view source on GitHub ↗
(projectId, entryGroupId, entryId, tagTemplateId)

Source from the content-addressed store, hash-verified

15'use strict';
16
17async function main(projectId, entryGroupId, entryId, tagTemplateId) {
18 // [START data_catalog_create_custom_entry]
19 // Import the Google Cloud client library.
20 const {DataCatalogClient} = require('@google-cloud/datacatalog').v1;
21 const datacatalog = new DataCatalogClient();
22
23 async function createCustomEntry() {
24 // Create a custom entry within an entry group.
25
26 /**
27 * TODO(developer): Uncomment the following lines before running the sample.
28 */
29 // const projectId = 'my_project';
30 // const entryGroupId = 'my_entry_group';
31 // const entryId = 'my_entry';
32 // const tagTemplateId = 'my_tag_template';
33
34 // Currently, Data Catalog stores metadata in the us-central1 region.
35 const location = 'us-central1';
36
37 // Delete any pre-existing Entry with the same name
38 // that will be used to create the new Entry.
39 try {
40 const entryName = datacatalog.entryPath(
41 projectId,
42 location,
43 entryGroupId,
44 entryId
45 );
46 await datacatalog.deleteEntry({name: entryName});
47 console.log(`Deleted Entry: ${entryName}`);
48 } catch (err) {
49 console.log('Entry does not exist.');
50 }
51
52 // Delete any pre-existing Entry Group with the same name
53 // that will be used to construct the new EntryGroup.
54 try {
55 const entryGroupName = datacatalog.entryGroupPath(
56 projectId,
57 location,
58 entryGroupId
59 );
60 await datacatalog.deleteEntryGroup({name: entryGroupName});
61 console.log(`Deleted Entry Group: ${entryGroupName}`);
62 } catch (err) {
63 console.log('Entry Group does not exist.');
64 }
65
66 // Delete any pre-existing Template with the same name
67 // that will be used to create a new Template.
68 const tagTemplateName = datacatalog.tagTemplatePath(
69 projectId,
70 location,
71 tagTemplateId
72 );
73
74 let tagTemplateRequest = {

Callers 1

Calls 1

createCustomEntryFunction · 0.85

Tested by

no test coverage detected