Google Cloud Platform logo

Google Cloud Asset Inventory: Node.js Client

release level npm version codecov

Cloud Asset Inventory is a storage service that keeps a five week history of Google Cloud Platform (GCP) asset metadata. It allows you to export all asset metadata at a certain timestamp or timeframe.

Using the client library

  1. [Select or create a Cloud Platform project][projects].

  2. [Enable billing for your project][billing].

  3. [Enable the Google Cloud Asset Inventory API][enable_api].

  4. [Set up authentication with a service account][auth] so you can access the API from your local workstation.

  5. Install the client library:

     npm install --save @google-cloud/asset
  6. Try an example:

  const asset = require('@google-cloud/asset');
  const client = new asset.v1beta1.AssetServiceClient({
    // optional auth parameters.
  });

  // Your Google Cloud Platform project ID
  const projectId = process.env.GCLOUD_PROJECT;
  const projectResource = client.projectPath(projectId);

  // var dumpFilePath = 'Dump file path, e.g.: gs://<my_bucket>/<my_asset_file>'
  const outputConfig = {
    gcsDestination: {
      uri: dumpFilePath,
    },
  };
  const request = {
    parent: projectResource,
    outputConfig: outputConfig,
  };

  // Handle the operation using the promise pattern.
  const [operation] = await client.exportAssets(request);
  // Operation#promise starts polling for the completion of the operation.
  const [result] = await operation.promise();
  // Do things with with the response.
  console.log(result);

The [Cloud Asset Node.js Client API Reference][client-docs] documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be in alpha. This means it is still a work-in-progress and under active development. Any release is subject to backwards-incompatible changes at any time.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

What's Next

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

[client-docs]: [product-docs]: https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project [billing]: https://support.google.com/cloud/answer/6293499#enable-billing [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=cloudasset.googleapis.com [auth]: https://cloud.google.com/docs/authentication/getting-started