0

我将使用哪个 Google Cloud Platform (GCP) REST API 路由来列出 GCP 项目?

即,哪个 GCP REST API 路由会给出类似于listCloud SDK ( gcloud) 命令输出的响应:

gcloud projects list

#=>

PROJECT_ID     NAME           PROJECT_NUMBER
. . .          . . .          . . .
4

1 回答 1

0
  1. You need to enable the "Cloud Resource Manager API" here

  2. Use google.cloudresourcemanager('v1').projects.list:

    curl \
    --header "Authorization: Bearer $(gcloud auth print-access-token)" \
    --location \
    --request GET \
    "https://cloudresourcemanager.googleapis.com/v1/projects"
    
    #=>
    
    {
      "projects": [
        . . .
      ]
    }
    
于 2017-07-01T09:48:38.857 回答