(projectId, entryGroupId, entryId)
| 15 | 'use strict'; |
| 16 | |
| 17 | async function main(projectId, entryGroupId, entryId) { |
| 18 | // [START data_catalog_create_fileset] |
| 19 | // Import the Google Cloud client library. |
| 20 | const {DataCatalogClient} = require('@google-cloud/datacatalog').v1; |
| 21 | const datacatalog = new DataCatalogClient(); |
| 22 | |
| 23 | async function createFileset() { |
| 24 | // Create a fileset 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 | |
| 33 | // Currently, Data Catalog stores metadata in the us-central1 region. |
| 34 | const location = 'us-central1'; |
| 35 | |
| 36 | // Delete any pre-existing Entry with the same name that will be used |
| 37 | // when creating the new Entry. |
| 38 | try { |
| 39 | const formattedName = datacatalog.entryPath( |
| 40 | projectId, |
| 41 | location, |
| 42 | entryGroupId, |
| 43 | entryId |
| 44 | ); |
| 45 | await datacatalog.deleteEntry({name: formattedName}); |
| 46 | } catch (err) { |
| 47 | console.log('Entry does not exist.'); |
| 48 | } |
| 49 | |
| 50 | // Delete any pre-existing Entry Group with the same name |
| 51 | // that will be used to create the new Entry Group. |
| 52 | try { |
| 53 | const formattedName = datacatalog.entryGroupPath( |
| 54 | projectId, |
| 55 | location, |
| 56 | entryGroupId |
| 57 | ); |
| 58 | await datacatalog.deleteEntryGroup({name: formattedName}); |
| 59 | } catch (err) { |
| 60 | console.log('Entry Group does not exist.'); |
| 61 | } |
| 62 | |
| 63 | // Construct the Entry Group for the Entry Group request. |
| 64 | const entryGroup = { |
| 65 | displayName: 'My Fileset Entry Group', |
| 66 | description: 'This Entry Group consists of ....', |
| 67 | }; |
| 68 | |
| 69 | // Construct the Entry Group request to be sent by the client. |
| 70 | const entryGroupRequest = { |
| 71 | parent: datacatalog.locationPath(projectId, location), |
| 72 | entryGroupId: entryGroupId, |
| 73 | entryGroup: entryGroup, |
| 74 | }; |
no test coverage detected