How to use @google-cloud/asset - 7 common examples

To help you get started, we’ve selected a few @google-cloud/asset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-asset / samples / createFeed.js View on Github external
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,
          },
        },
github googleapis / nodejs-asset / samples / quickstart.js View on Github external
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),
        },
      },
github googleapis / nodejs-asset / samples / getFeed.js View on Github external
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();
}
github googleapis / nodejs-asset / samples / listFeeds.js View on Github external
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();
}
github googleapis / nodejs-asset / samples / deleteFeed.js View on Github external
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();
}
github googleapis / nodejs-asset / samples / getBatchAssetHistory.js View on Github external
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),
        },
      },
github googleapis / nodejs-asset / samples / exportAssets.js View on Github external
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,
        },
      },
    };

@google-cloud/asset

Cloud Asset API client for Node.js

Apache-2.0
Latest version published 23 days ago

Package Health Score

89 / 100
Full package analysis

Popular @google-cloud/asset functions