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

Function main

asset/snippets/exportAssetsBigquery.js:22–61  ·  view source on GitHub ↗
(dataSet, table)

Source from the content-addressed store, hash-verified

20// usage: node exportAssetsBigquery.js <projects/project_id/datasets/dataset_id> <table_name>
21
22async function main(dataSet, table) {
23 // [START asset_quickstart_export_assets_bigquery]
24 /**
25 * TODO(developer): Uncomment these variables before running the sample.
26 */
27 // const dataSet = 'projects/project_id/datasets/dataset_id';
28 // const table = 'mytable';
29
30 const {AssetServiceClient} = require('@google-cloud/asset');
31 const client = new AssetServiceClient();
32
33 async function exportAssetsBigquery() {
34 const projectId = await client.getProjectId();
35 const projectResource = client.projectPath(projectId);
36 const dataset = dataSet;
37
38 const request = {
39 parent: projectResource,
40 outputConfig: {
41 bigqueryDestination: {
42 dataset: `projects/${projectId}/${dataset}`,
43 table: table,
44 force: true,
45 },
46 },
47 };
48
49 // Handle the operation using the promise pattern.
50 const [operation] = await client.exportAssets(request);
51
52 // Operation#promise starts polling for the completion of the operation.
53 const [result] = await operation.promise();
54
55 // Do things with with the response.
56 console.log(result);
57 }
58
59 exportAssetsBigquery();
60 // [END asset_quickstart_export_assets_bigquery]
61}
62
63main(...process.argv.slice(2)).catch(err => {
64 console.error(err.message);

Callers 1

Calls 1

exportAssetsBigqueryFunction · 0.85

Tested by

no test coverage detected