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