Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main(feedId, assetNames, topicName) {
// [START asset_quickstart_create_feed]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function createFeed() {
const projectId = await client.getProjectId();
// TODO(developer): Choose asset names, such as //storage.googleapis.com/[YOUR_BUCKET_NAME].
// const assetNames = ['ASSET_NAME1', 'ASSET_NAME2', ...];
const request = {
parent: `projects/${projectId}`,
feedId: feedId,
feed: {
assetNames: assetNames.split(','),
feedOutputConfig: {
pubsubDestination: {
topic: topicName,
},
},
async function main(assetNames) {
// [START asset_quickstart]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function quickstart() {
const projectId = await client.getProjectId();
const projectResource = client.projectPath(projectId);
// TODO(developer): Choose asset names, such as //storage.googleapis.com/[YOUR_BUCKET_NAME].
// const assetNames = ['ASSET_NAME1', 'ASSET_NAME2', ...];
const request = {
parent: projectResource,
assetNames: assetNames.split(','),
contentType: 'RESOURCE',
readTimeWindow: {
startTime: {
seconds: Math.floor(new Date().getTime() / 1000),
},
},
async function main(feedName) {
// [START asset_quickstart_get_feed]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function getFeed() {
const request = {
name: feedName,
};
// Handle the operation using the promise pattern.
const result = await client.getFeed(request);
// Do things with with the response.
console.log(util.inspect(result, {depth: null}));
// [END asset_quickstart_get_feed]
}
getFeed();
}
async function main() {
// [START asset_quickstart_list_feeds]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function listFeeds() {
const projectId = await client.getProjectId();
const request = {
parent: `projects/${projectId}`,
};
// Handle the operation using the promise pattern.
const result = await client.listFeeds(request);
// Do things with with the response.
console.log(util.inspect(result, {depth: null}));
// [END asset_quickstart_list_feeds]
}
listFeeds();
}
async function main(feedName) {
// [START asset_quickstart_delete_feed]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function deleteFeed() {
const request = {
name: feedName,
};
// Handle the operation using the promise pattern.
const result = await client.deleteFeed(request);
// Do things with with the response.
console.log(util.inspect(result, {depth: null}));
// [END asset_quickstart_delete_feed]
}
deleteFeed();
}
async function main(assetNames) {
// [START asset_quickstart_batch_get_assets_history]
const util = require('util');
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function batchGetAssetsHistory() {
const projectId = await client.getProjectId();
const projectResource = client.projectPath(projectId);
// TODO(developer): Choose asset names, such as //storage.googleapis.com/[YOUR_BUCKET_NAME].
// const assetNames = ['ASSET_NAME1', 'ASSET_NAME2', ...];
const request = {
parent: projectResource,
assetNames: assetNames.split(','),
contentType: 'RESOURCE',
readTimeWindow: {
startTime: {
seconds: Math.floor(new Date().getTime() / 1000),
},
},
async function main(dumpFilePath) {
// [START asset_quickstart_export_assets]
const {AssetServiceClient} = require('@google-cloud/asset');
const client = new AssetServiceClient();
async function exportAssets() {
const projectId = await client.getProjectId();
const projectResource = client.projectPath(projectId);
// TODO(developer): choose the dump file path
// const dumpFilePath = 'Dump file path, e.g.: gs:///'
const request = {
parent: projectResource,
outputConfig: {
gcsDestination: {
uri: dumpFilePath,
},
},
};