(assetNames, contentType)
| 20 | // usage: node getBatchAssetHistory "//storage.googleapis.com/<BUCKET_NAME>" |
| 21 | |
| 22 | async function main(assetNames, contentType) { |
| 23 | // [START asset_quickstart_batch_get_assets_history] |
| 24 | /** |
| 25 | * TODO(developer): Uncomment these variables before running the sample. |
| 26 | */ |
| 27 | // const assetNames = '//storage.googleapis.com/<BUCKET_NAME1>,//storage.googleapis.com/<BUCKET_NAME2>'; |
| 28 | // const contentType = 'RESOURCE'; |
| 29 | |
| 30 | const util = require('util'); |
| 31 | const {AssetServiceClient} = require('@google-cloud/asset'); |
| 32 | |
| 33 | const client = new AssetServiceClient(); |
| 34 | |
| 35 | async function batchGetAssetsHistory() { |
| 36 | const projectId = await client.getProjectId(); |
| 37 | const projectResource = `projects/${projectId}`; |
| 38 | // TODO(developer): Choose asset names, such as //storage.googleapis.com/[YOUR_BUCKET_NAME]. |
| 39 | // const assetNames = ['ASSET_NAME1', 'ASSET_NAME2', ...]; |
| 40 | |
| 41 | const request = { |
| 42 | parent: projectResource, |
| 43 | assetNames: assetNames.split(','), |
| 44 | contentType: contentType, |
| 45 | readTimeWindow: { |
| 46 | startTime: { |
| 47 | seconds: Math.floor(new Date().getTime() / 1000), |
| 48 | }, |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | // Handle the operation using the promise pattern. |
| 53 | const result = await client.batchGetAssetsHistory(request); |
| 54 | // Do things with with the response. |
| 55 | console.log(util.inspect(result, {depth: null})); |
| 56 | // [END asset_quickstart_batch_get_assets_history] |
| 57 | } |
| 58 | batchGetAssetsHistory(); |
| 59 | } |
| 60 | |
| 61 | main(...process.argv.slice(2)).catch(err => { |
| 62 | console.error(err.message); |
no test coverage detected