Skip to content

Commit

Permalink
docs: use repo-meta to generate README (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored and bcoe committed May 13, 2019
1 parent 4f88558 commit 092fa4c
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 168 deletions.
8 changes: 0 additions & 8 deletions packages/google-cloud-asset/.cloud-repo-tools.json

This file was deleted.

13 changes: 13 additions & 0 deletions packages/google-cloud-asset/.repo-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "asset",
"name_pretty": "Cloud Asset Inventory",
"product_documentation": "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview",
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/asset/latest/",
"issue_tracker": "https://issuetracker.google.com/savedsearches/559757",
"release_level": "alpha",
"language": "nodejs",
"repo": "googleapis/nodejs-asset",
"distribution_name": "@google-cloud/asset",
"api_id": "cloudasset.googleapis.com",
"requires_billing": true
}
134 changes: 82 additions & 52 deletions packages/google-cloud-asset/README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,120 @@
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
[//]: # "To regenerate it, use `python -m synthtool`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# [Google Cloud Asset Inventory: Node.js Client](https://github.com/googleapis/nodejs-asset)
# [Cloud Asset Inventory: Node.js Client](https://github.com/googleapis/nodejs-asset)

[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style&#x3D;flat)](https://cloud.google.com/terms/launch-stages)
[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/@google-cloud/asset.svg)](https://www.npmjs.org/package/@google-cloud/asset)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-asset/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-asset)

[Cloud Asset Inventory](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview) 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](#using-the-client-library)

Cloud Asset API client for Node.js


* [Cloud Asset Inventory Node.js Client API Reference][client-docs]
* [Cloud Asset Inventory Documentation][product-docs]
* [github.com/googleapis/nodejs-asset](https://github.com/googleapis/nodejs-asset)

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

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

**Table of contents:**


* [Quickstart](#quickstart)
* [Before you begin](#before-you-begin)
* [Installing the client library](#installing-the-client-library)
* [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Versioning](#versioning)
* [Contributing](#contributing)
* [License](#license)

## Using the client library
## Quickstart

1. [Select or create a Cloud Platform project][projects].
### Before you begin

1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].

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

1. [Enable the Cloud Asset Inventory API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

1. Install the client library:
### Installing the client library

```bash
npm install @google-cloud/asset
```

npm install --save @google-cloud/asset

1. Try an example:
### Using the client library

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

// Your Google Cloud Platform project ID
const projectId = await client.getProjectId();
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);
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,
contentType: 'RESOURCE',
readTimeWindow: {
startTime: {
seconds: Math.floor(new Date().getTime() / 1000),
},
},
};

// Handle the operation using the promise pattern.
const result = await client.batchGetAssetsHistory(request);
// Do things with with the response.
console.log(util.inspect(result, {depth: null}));

```
The [Cloud Asset Node.js Client API Reference][client-docs] documentation
## Samples
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-asset/tree/master/samples) directory. The samples' `README.md`
has instructions for running the samples.
| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Export Assets | [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/exportAssets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/exportAssets.js,samples/README.md) |
| Get Batch Asset History | [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/getBatchAssetHistory.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/getBatchAssetHistory.js,samples/README.md) |
| Asset History Quickstart | [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
The [Cloud Asset Inventory Node.js Client API Reference][client-docs] documentation
also contains samples.
## Versioning
This library follows [Semantic Versioning](http://semver.org/).
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][launch_stages]
[launch_stages]: https://cloud.google.com/terms/launch-stages
Expand All @@ -88,21 +129,10 @@ Apache Version 2.0
See [LICENSE](https://github.com/googleapis/nodejs-asset/blob/master/LICENSE)
## What's Next

* [Cloud Asset Documentation][product-docs]
* [Cloud Asset Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-asset](https://github.com/googleapis/nodejs-asset)

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

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

[client-docs]: https://cloud.google.com/nodejs/docs/reference/asset/latest/
[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
[auth]: https://cloud.google.com/docs/authentication/getting-started
12 changes: 5 additions & 7 deletions packages/google-cloud-asset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@
"scripts": {
"cover": "nyc --reporter=lcov mocha test/*.js && nyc report",
"docs": "jsdoc -c .jsdoc.js",
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
"lint": "eslint '**/*.js'",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"system-test": "mocha system-test/*.js smoke-test/*.js --timeout 600000",
"test-no-cover": "mocha test/*.js",
"test": "npm run cover",
"fix": "eslint --fix '**/*.js'",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
"docs-test": "linkinator docs -r --skip 'www.googleapis.com|github.com/googleapis/nodejs-asset/blob/master/samples/exportAssets.js|github.com/googleapis/nodejs-asset/blob/master/samples/getBatchAssetHistory.js'",
"predocs-test": "npm run docs"
},
"dependencies": {
Expand All @@ -47,19 +46,18 @@
"protobufjs": "^6.8.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"codecov": "^3.0.4",
"eslint": "^5.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-node": "^9.0.0",
"eslint-plugin-prettier": "^3.0.0",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"jsdoc": "^3.6.2",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"linkinator": "^1.1.2",
"mocha": "^6.0.0",
"nyc": "^14.0.0",
"power-assert": "^1.6.0",
"prettier": "^1.13.7",
"linkinator": "^1.1.2"
"prettier": "^1.13.7"
}
}
86 changes: 86 additions & 0 deletions packages/google-cloud-asset/samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `python -m synthtool`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# [Cloud Asset Inventory: Node.js Samples](https://github.com/googleapis/nodejs-asset)

[![Open in Cloud Shell][shell_img]][shell_link]



## Table of Contents

* [Before you begin](#before-you-begin)
* [Samples](#samples)
* [Export Assets](#export-assets)
* [Get Batch Asset History](#get-batch-asset-history)
* [Asset History Quickstart](#asset-history-quickstart)

## Before you begin

Before running the samples, make sure you've followed the steps outlined in
[Using the client library](https://github.com/googleapis/nodejs-asset#using-the-client-library).

## Samples



### Export Assets

Export asserts to specified dump file path.

View the [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/exportAssets.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/exportAssets.js,samples/README.md)

__Usage:__


`node exportAssets.js <gs:my-bucket/my-assets.txt>`


-----




### Get Batch Asset History

Batch get history of assets.

View the [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/getBatchAssetHistory.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/getBatchAssetHistory.js,samples/README.md)

__Usage:__


`node getBatchAssetHistory "storage.googleapis.com/<BUCKET_NAME>"`


-----




### Asset History Quickstart

Batch get history of assets.

View the [source code](https://github.com/googleapis/nodejs-asset/blob/master/samples/quickstart.js).

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/quickstart.js,samples/README.md)

__Usage:__


`node getBatchAssetHistory "storage.googleapis.com/<BUCKET_NAME>"`






[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-asset&page=editor&open_in_editor=samples/README.md
[product-docs]: https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview
60 changes: 60 additions & 0 deletions packages/google-cloud-asset/samples/exportAssets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright 2018, Google, LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// sample-metadata:
// title: Export Assets
// description: Export asserts to specified dump file path.
// usage: node exportAssets.js <gs://my-bucket/my-assets.txt>

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://<my_bucket>/<my_asset_file>'

const request = {
parent: projectResource,
outputConfig: {
gcsDestination: {
uri: dumpFilePath,
},
},
};

// 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);
}
exportAssets();
// [END asset_quickstart_export_assets]
}

main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
Loading

0 comments on commit 092fa4c

Please sign in to comment.