@google-cloud/resource

中文文档
1.2.1发布于 2020/07/11Apache-2.0TypeScriptCommonJS近 30 天下载 6625

Cloud Resource Manager Client Library for Node.js

此软件包已被标记为弃用

@google-cloud/resource has been renamed to @google-cloud/resource-manager

原始使用文档
文档目录9 节
  1. Quickstart
  2. Before you begin
  3. Installing the client library
  4. Using the client library
  5. Samples
  6. Supported Node.js Versions
  7. Versioning
  8. Contributing
  9. License

Google Cloud Platform logo

Google Cloud Resource Manager API: Node.js Client

release level npm version codecov

Node.js idiomatic client for Cloud Resource Manager API.

Google Cloud Platform provides container resources such as Organizations and Projects, that allow you to group and hierarchically organize other Cloud Platform resources. This hierarchical organization lets you easily manage common aspects of your resources such as access control and configuration settings. The Cloud Resource Manager API enables you to programmatically manage these container resources.

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

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Google Cloud Resource Manager API API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/resource

Using the client library

// Imports the Google Cloud client library
const {Resource} = require('@google-cloud/resource');

// Creates a client
const resource = new Resource();

async function quickstart() {
  // Lists current projects
  const [projects] = await resource.getProjects();

  console.log('Projects:');
  projects.forEach(project => console.log(project.id));
}
quickstart();

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

SampleSource CodeTry it
List Projectssource codeOpen in Cloud Shell
Quickstartsource codeOpen in Cloud Shell

The Google Cloud Resource Manager API Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.

Client libraries targetting some end-of-life versions of Node.js are available, and can be installed via npm dist-tags. The dist-tags follow the naming convention legacy-(version).

Legacy Node.js versions are supported as a best effort:

  • Legacy versions will not be tested in continuous integration.
  • Some security patches may not be able to be backported.
  • Dependencies will not be kept up-to-date, and features will not be backported.

Legacy tags available

  • legacy-8: install client libraries from this dist-tag for versions compatible with Node.js 8.

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.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its template in this directory.

License

Apache Version 2.0

See LICENSE

版本与发布记录

@google-cloud/resource 共发布 29 个版本,首次发布于 2016/08/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.1latest2020/07/116 年前
1.2.02020/06/036 年前
1.1.5legacy-82019/12/066 年前
1.1.42019/11/157 年前
1.1.32019/07/317 年前
1.1.22019/06/277 年前

关于 @google-cloud/resource 的常见问题

@google-cloud/resource 是什么?

Cloud Resource Manager Client Library for Node.js注意:该包已被作者标记为弃用——@google-cloud/resource has been renamed to @google-cloud/resource-manager

如何安装 @google-cloud/resource?

在项目目录运行 npm install @google-cloud/resource,或使用 pnpm add / yarn add / bun add。

@google-cloud/resource 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@google-cloud/resource 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@google-cloud/resource 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@google-cloud/resource 可以商用吗?

@google-cloud/resource 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@google-cloud/resource 的下载量有多少?

根据 npm 官方下载统计,@google-cloud/resource 在 2026/10/17 – 2026/11/15 这 30 天内被下载 6,625 次,日均约 221 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@google-cloud/resource 还在维护吗?

最新版本 1.2.1 发布于 2020/07/11(6 年前);至今共发布 29 个版本,其中过去 12 个月发布了 0 个;首次发布于 2016/08/12。作者已将其标记为弃用,新项目建议寻找替代方案。