启用 App Optimize API

如需使用 App Optimize API,您必须在打算创建和管理用量与费用报告资源的 Google Cloud 项目 中启用该 API。 您可以使用 Google Cloud 控制台或 Google Cloud CLI 启用该 API。

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud的新用户, 请创建一个账号,以便在 真实场景中评估我们产品的性能。新客户还可获享 $300 赠金,用于 运行、测试和部署工作负载。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project.

启用 API

如需启用 App Optimize API,请按照以下其中一组说明操作:

控制台

  1. 在 Google Cloud 控制台中,前往 API 库

    前往 API 库

  2. 如果出现提示,请选择您的 Google Cloud 项目。

  3. 在 App Optimize API 页面上,点击启用

gcloud

  1. 安装并初始化 Google Cloud CLI
  2. 如需启用 App Optimize API,请运行以下命令:

    gcloud services enable appoptimize.googleapis.com --project=PROJECT_ID
    

    请将 PROJECT_ID 替换为您的 Google Cloud 项目 ID。

验证 API 是否已启用

如需检查 App Optimize API 是否已启用,请按照以下其中一组说明操作:

控制台

  1. 在 Google Cloud 控制台中,前往已启用的 API 和服务页面。

    前往“已启用的 API 和服务”

  2. 在列表中,找到并确认列出了 App Optimize API

gcloud

  1. 运行以下命令:

    gcloud services list --enabled --project=PROJECT_ID --filter="NAME:appoptimize.googleapis.com"
    
  2. 如果 API 已启用,输出内容将包含:

    NAME                        TITLE
    appoptimize.googleapis.com  App Optimize API
    

后续步骤